Rails

Rails is a web application development framework written in Ruby language. It is designed to make programming web applications easier and fun through coding less. David Heinemeier Hansson created it. He named it “Ruby on Rails but it is often called “Rails.”

Rails combines the Ruby language with HTML, CSS and JavaScript to create a web application that runs on web server. Because Rails is run on server it is considered to server-side web application development platform.

Daniel Keho states in his book, Learning Ruby on Rails that “Rails is popular and widely used because its conventions are pervasive and astute.”

Rails philosophy has a few guiding principles:

  • DRY — “Don’t Repeat Yourself” — suggests that writing the same code over and over again is a bad thing. Duplication can make an application more complex, difficult to maintain and lead to unintended bugs.
  • Convention Over Configuration — means that Rails makes assumptions about what you want to do and how you’re going to do it, rather than requiring you to specify every little thing through endless configuration files. This is believed to increase productivity and ease the collaboration with other developers because they have the same defaults.
  • REST is the best pattern for web applications — organizing your application around resources and standard HTTP verbs is the fastest way to go.

Rails can get complicated too since there are assumptions made therefore different developers will choose to do things differently. It is also believed that to avoid repetition Rails offers default behavior that is like magic but in reality the implementation of that code is hidden in the Rails code library which is complex for a beginner to follow or find.

The core of Rails is the MVC architecture, which stands for Model, View and Controller. The benefits of using MVC are:

· Separating the business logic from the user interface

· Helps to write DRY code

· The separation of code makes it easier for maintenance

Model: It represents the data of the application and the rules to manipulate the data. The bulk of your applications business logic will be concentrated in the models.

Views: It represents the user interface. It often the HTML, CSS and JavaScript files. This code preform tasks related to presenting the data to the web browser.

Controllers: They are glue between the models and views. Rails controllers are responsible for processing the incoming request from web browser, interrogating the models for data and then passing that data on to the views for presentation.