Ruby on Rails 3: The future of online web applications.
Posted on Saturday, November 27, 2010
- Cloud Sites Update: New Control Panel & Faster MySQLThursday, April 9, 2015
- Introducing New Server Networking FeaturesTuesday, March 10, 2015
- Getting started with Docker in minutes using Docker MachineFriday, February 20, 2015
- MEAN & Socket.IO Integration TutorialThursday, September 11, 2014
- Getting Started with MEAN StackWednesday, August 6, 2014
- How To Install Ruby on Rails on UbuntuSunday, December 29, 2013
- How to Add Swap on UbuntuMonday, December 30, 2013
- How To Deploy Django on Nginx, Gunicorn with PostgresTuesday, April 8, 2014
- Few CSS tricks you may not knowFriday, October 27, 2006
- CentOS 6 to CentOS 7 Upgrade ProcedureWednesday, July 16, 2014
At the moment, PHP is undoubtedly the leading development language of online applications. It’s simplistic syntax and the prevalent amount of tutorials for it makes it a perfect starter language for online developers. The ability to include miniature chunks of code on any ordinary HTML web page makes getting started with PHP exceptionally easy.
However, there’s a new player on the block, Rails. With the recent release of Rails 3, building the next new killer application seems much easier and faster to accomplish. Rails 3 facilitates the development of online applications by providing developers with a powerful, scalable & expandable framework. Rails 3 has arguably introduced web developers with one of the finest object oriented programming languages.
There are a fair amount of powerful PHP frameworks that can be named. However, they all lack the powerful OOP features that Rails 3 provides. Models can be created as objects, then can be modified/saved into a database and destroyed at anytime. The powerful framework handles sessions, security, XSS, SQL injections and secures everything. However, the best part of this is the ActiveRecord ability to make optimized SQL queries without spending up all your time.
The workflow of creating a blog would be the following:
- Create a new Rails 3 application
- Create a post model (using a built-in simplistic scaffold application) with the following values
- Create a comment model (same scaffold application) with the following values:
- Content ID
- Related Post ID
- Use the automatically generated Post controller and write the following in it:
- Use the automatically generated Comment controller and write the following:
There is much more to it, however, everything just makes sense. I strongly suggest taking a look at Rails for Zombies which is a simple introduction to Rails. Also, watching the Rails 3 screencasts won’t take more than a couple of minutes of your time but you will undoubtedly be interested.
Frankly, here’s a small comparison of a little query that gets the 5 latest comments for a blog, both in PHP and Rails. You be the judge.
<?php mysql_query("SELECT * FROM comments WHERE id=1 LIMIT 5"); ?>
comments = Comment.where(:id => 1).limit(5)
Also, if you have nested objects, you can obviously do the following with Ruby:
hard_drive = Client.where(:id => 50).computer.hard_drive
I don’t even want to start thinking of how complex and time consuming writing a query for the above code, where it’s all done and completed within minutes. I personally think that any advanced (or beginner) programmers should give it a shot. Nothing but advantages so far here, I’ve yet to run into a Rails issue. I’d love to hear others constructive output regarding this, I know I might sound a bit biased however I have been very impressed by Rails.
-DScomments powered by Disqus