Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools

Ruby on Rails

Rails is a web-application framework that includes everything needed to create database-backed web applications according to the Model-View-Control pattern. This pattern splits the view (also called the presentation) into “dumb” templates that are primarily responsible for inserting pre-built data in between HTML tags. The model contains the “smart” domain objects (such as User, Trail,Group)that holds all the business logic and knows how to persist themselves to a database. The controller handles the incoming requests by manipulating the model and directing data to the view.Such as in case of Message controller we have New,Update,Create(for actually creating message into database), show methods to handle these requests.

Overview of automatically created folders


Most of the development happens within this directory. Holds all the code that's specific to this particular application.


Holds controllers that should be named like trails_controller.rb for automated URL mapping.All controllers should descend from ApplicationController which itself descends from ActionController::Base.Each of these files should named after the model they control followed by _controller.rb for automatic URL mapping.


Holds models that should be named like Trail.rb.Most models will descend from ActiveRecord::Base.


Holds the template files for the view that should be named like trails/index.html.erb for the trails#index action. All views use eRuby syntax.


Holds the template files for layouts to be used with views. This models the common header/footer method of wrapping views.In our application application.html.erb is default layout.


Holds view helpers that should be named like location_tracker_helper.rb .This helper contains a function which implements start trail button.Usually helper contains functions that we want to reuse in views. Helpers can be used to wrap functionality for your views into methods.If you want to generate automatically then you can use script/generate.


Configuration files for the Rails environment, the routing map, the database, and other dependencies.


Contains the database schema in schema.rb. db/migrate contains all the sequence of Migrations for your schema.


This directory is where your application documentation will be stored when generated using <tt>rake doc:app</tt>


Application specific libraries. Basically, any kind of custom code that doesn't belong under controllers, models, or helpers. This directory is in the load path.


The directory available for the web server. Contains subdirectories for images, stylesheets,and javascripts. Also contains the dispatchers and the default HTML files. This should be set as the DOCUMENT_ROOT of your web server.


Helper scripts for automation and generation.


Unit and functional tests along with fixtures. When using the script/generate scripts, template test files will be generated for you and placed in this directory.


External libraries that the application depends on. Also includes the plugins subdirectory.If the app has frozen rails, those gems also go here, under vendor/rails/. This directory is in the load path.

teaching/labs/xp/2009b/how_rails_works.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2023