Ruby on Rails Developers Forum

In a default configuration, a model in a Ruby on Rails framework maps to a table in a database. By convention, a model named User will map to the database table users, and the model will have a filename user.rb within app/models, while developers can choose to use whatever model name and database table name they wish, this is not a common practice and it’s usually discouraged because Rails philosophy is to use convention over configuration.

 

A controller is the component of Rails that responds to external request from the web server to the application, and respond to the external request by determining which view file to render. The controller may also have to query the model directly for information and pass these onto the view. A controller may contain one or more actions. In Ruby on Rails, action is typically a basic unit which describes a single rule on how to respond to a specific external web-browser request. Also note that, if a controller/action is not mapped to the Rails router, the controller/action will be directly inaccessible to external web requests. By convention, Rails encourage developers to use a RESTful route which contain actions named create, new, edit, update, destroy, and index, as these are routed automatically by convention in the routes file if specified.A view typically is a erb file in the default configuration of Rails. It is typically converted to output html at run-time, although in theory any formats can be used as a view.

 

Ruby on Rails includes tools that make common development tasks easier “out of the box”, such as scaffolding that can automatically construct some of the models and views needed for a basic website. Also included are WEBrick, a simple Ruby web server that is distributed with Ruby, and Rake, a build system, distributed as a gem. Together with Ruby on Rails these tools provide a basic development environment.Ruby on Rails relies on a web server to run it. Mongrel was generally preferred over WEBrick at the time of writing[citation needed], but it can also be run by Lighttpd, Apache, Cherokee, Hiawatha, nginx (either as a module – Passenger for example – or via CGI, FastCGI or mod_ruby), and many others. From 2008 onwards, the Passenger web server replaced Mongrel as the most used web server for Ruby on Rails.

 

Ruby on Rails is also noteworthy for its extensive use of the JavaScript libraries Prototype and

Script.aculo.us for Ajax. Ruby on Rails initially utilized lightweight SOAP for web services; this was later replaced by RESTful web services. Ruby on Rails 3.0 uses a technique called Unobtrusive JavaScript to separate the functionality (or logic) from the structure of the web page. jQuery is fully supported as a replacement for Prototype and in Rails 3.1 is the default javascript library, reflecting an industry-wide move towards using jQuery.

 

Since version 2.0, Ruby on Rails by default offers both HTML and XML as output formats. The latter is the facility for RESTful web services.The server uses embedded ruby in the HTML views with files having an html.erb extension. Other templating methods are available such as HAML which removes much of the normal page ‘clutter’ (for example html ‘<‘ and ‘>’ and ruby indent ‘end’s)

 

Ruby on Rails is separated into various packages, namely ActiveRecord (an object-relational mapping system for database access), ActiveResource (provides web services), ActionPack, ActiveSupport and ActionMailer. Prior to version 2.0, Ruby on Rails also included the Action Web Service package that is now replaced by Active Resource. Apart from standard packages, developers can make plugins to extend existing packages.

 

Ruby On Rails is an impressive web development framework that will soon reach version 1.0. While there’s a lot of buzz, it can sometimes be difficult to discern the steak beneath the sizzle. Curt Hibbs walks through the features and pieces of Ruby On Rails to show how it fits together and where its big benefits come from.

Processing your request, Please wait....

Leave a Reply