Professional Documents
Culture Documents
Ruby On Rails
Ruby On Rails
Ruby On Rails
By,
M.KEERTHI TEJA
07AQ1A0532(cse)
CHILKUR BALAJI INSTITUTE OF TECHNOLOGY 1
Ruby on Rails
The amazing productivity claims of Rails is the current buzz in the web
development community. If your job is to create or manage web
applications that capture and manipulate relational database from a web-
based user interface, then Ruby on Rails may be the solution you’ve been
looking for to make your web development life easier.
2
CHILKUR BALAJI INSTITUTE OF TECHNOLOGY
What is Ruby?
• Ruby is a pure object-oriented programming language with a super clean
syntax that makes programming elegant and fun.
– In Ruby, everything is an object
• Ruby is an interpreted scripting language, just like Perl, Python and PHP.
3
CHILKUR BALAJI INSTITUTE OF TECHNOLOGY
What is Rails?
• Rails is an open source Ruby framework for developing database-backed
web applications.
• All layers in Rails are built to work together so you Don’t Repeat Yourself
and can use a single language from top to bottom.
• Action Mailer
• Instant Rails is a software that provides Rails runtime. This software comes
with a bundle contains Ruby, Rails, Apache, and MySQL and all is
preconfigured and ready to run.
Now to start rails server locate to project folder what we have created
now by using cd project_name (ex: cd demo)
app
It contains all the code of that particular project. It also contains three
main folders which reflects the MVC architecture.
app/controllers
It contains the controller classes. These controllers mainly handles web
requests from users.
app/models
This directory contains the classes which will model and grab the data stored
in application’s database.
app/views
The view subdirectory holds the display templates to fill in with data from
our application, convert to HTML, and return to the user’s browser.
app/views/layouts
Holds the template files for layouts to be used with views. This models the
common header/footer method of wrapping views. In your views, define
a layout using the layout :default and create a file named
default.html.erb. Inside default.html.erb,
call <% yield %> to render the view using this layout.
app/helpers
The helpers directory holds the helper classes and these classes assist the
model, view, and controller classes.
config
Configuration files for the Rails environment (environment.rb), database
configuration (database.yml) and routing of incoming user requests (routes.rb).
db
Contains the database schema in schema.rb. You can manage the relational
database with scripts you create and place in this directory
doc
This directory is where your application documentation will be stored. This
documentation can automatically generated using the command rake doc:app
lib
Contains the application libraries. Generally the code which doesn’t belongs to
controllers, models, helpers is stored here and this directory is set in load path.
public
The directory available for the web server. Contains subdirectories for images,
stylesheets,and java scripts.
script
Helper scripts for automation and generation. (example launching a web
server)
test
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.
vendor
External libraries such as third party libraries are stored here.
Model: Model will stores the information about each table of a database.
It also do some primary validation of data before storing into database.
View: View is generally the interface of your application. Views are often
HTML pages with some embedded ruby code. Views handle the job of
providing the data to web browser.
Controller: Controller mainly handles the incoming requests from the web
browser, interrogating the models for data, and passing that data on to
the views for presentation.
• Unless you try to do something beyond what you have already mastered, you will
never grow. – Ralph Waldo Emerson
20
CHILKUR BALAJI INSTITUTE OF TECHNOLOGY