an essay on rails
What is Rails?
Ruby on Rails is a web development framework written in Ruby. It was extracted from code in a 37 Signals web application Basecamp. Since it’s inception, its purpose was to speed up the development process for web applications. It has strong integrated support for JavaScript and databases that make integrating AJAX (Asynchronies JavaScript and XML) a faster and more enjoyable process for developers. Because of the philosophies in the Rails community, the structure of the project also speeds up development and maintenance of the Web App.
Philosophy
Model-View-Controller
The MVC pattern is the most predominant theme in the Rails framework. The Model is your data object and is implement through the ruby project ActiveRecord. The Controller is a class the holds the business and application logic and handles the basic routing. The View is handles by ERB files. These are html files that have ruby tags in them allowing data to be added.
Convention over Configuration. Another prominent philosophy in the Rails community is Convention over Configuration. The designers of Rails felt it was more import to take the time to come up with appropriate settings then have giant configuration files scattered throughout the project. While this does make the project easier to get up and running, if you need to do something that is out of sync with the Rails philosophy, it will take a little bit of work.
Don’t Repeat Yourself.
The DRY philosophy is a major philosophy in Rails code and means to stay DRY are built into the Framework. Every controller has a helper class that contains methods needed in views. The application also has a helper class, allowing the programmer to create custom tags for ERB files, allowing even HTML and JavaScript to be refectories. Views can also be made DRY by creating partial views, which can be used in other views.
Representational State Transfer (RESTful).
RESTful web services are also built into the framework. REST is a design pattern for web services. There are four functions in a RESTful service: create, update, delete, and read. All data is sent and returned in XML format. Rails has been built so that an entire RESTful service can be built using a single command. The Rails community has shied away from the WS-* primarily due to its complexity and unpredictability in any developer can setup and commands they want. Other benefits include shorter response times due to caching.
Reasons for Rails’ Gain
Rails has shot into the spotlight in the past few years. It has been heralded as a great productivity increaser and all over the web there are blog posts about teams scrapping their half finish projects and for Rails and still completing them ahead of time. Rails isn’t the magic solution to web development but it does solve some things right out of the gate and make others more simplified.
If the web project does not fall into the basic category of the CRM and depends on database interactions then Rails will do the job well. It has out of the box support for most major database so programmers do not have to spend time setting up database connection. In addition, Rails has integrated support for the Prototype and the Scriptaculous JavaScript libraries, which give the developer built in support for AJAX and interactive pages. If there is a need for a JavaScript functionality not provided by the libraries, the developer can use ruby to write JavaScript code using RJS (Ruby JavaScript). Deployment tools are also built into the framework such as Rake, which aid in the deployments of projects.
The Influence of Rails.
The rise in popularity of Rails has greatly effected web development. There has been a rise in frameworks across the major web development languages. Python’s main contender is Django but TurboGears also has had a lot of press. Both are structured very similar to Rails and are often compared. The PHP community is noticing this as well and its main project is CakePHP. Microsoft has also taken notice and its next version of ASP.net is based on the MVC structure. There are also Java projects that are being worked on with a similar structure.
Rails has also effected Ruby. Ruby went from being a relatively obscure language to being the ninth most popular language. Sun has taken notice of Ruby. They have provided a large amount of resources for Ruby and Rails developers and have setup a developer site. JRuby has also had a spike in interest.
Drawbacks with Rails
Rails does have some drawbacks. The main problem is scaling, think twitter . Rails is best run with either the Mongrel server, a server written in Ruby, or fast-cgi; however, these are both slow solutions. Because of a problem with the mod_ruby project, Rails does not integrate with the Apache server like Python can. This problem made headlines recently, when there was a rumor leaked that the social network site Twitter would be dropping Rails in favor of tools that are more scalable.