Sunday, 26 August 2012

Ruby Now on Rails!! Intro !

Rails Introduction:
-->Web application development framework written in ruby.
-->Less code can accomplish more than what other programming languages can do.
-->If we use it the right way it is the best,else if u try to bring the old programming practices into it ,it will end up as a big mess.
-->It is an open source framework for developing database backed web application.
-->No compilation phase is required.

Strength of Rails:
-->Metaprogramming : Other frameworks use extensive code generation from scratch. Metaprogramming techniques use programs to write programs. Ruby is one of the best languages for metaprogramming, and Rails uses this capability well.
-->Active Records:Rails have active record framework which saves objects to databases.
-->Convention over Configuration:No need of writing much configuration.If u follow the naming syntax properly,configuration is not necessary.
-->Scaffolding:You often create temporary code in the early stages of development to help get an application up quickly and see how major components work together.
-->Built in testing:Rails creates simple automated tests you can then extend. Rails also provides supporting code called harnesses and fixtures that make test cases easier to write and run.
-->Three environments:Rails provide three different environments,one for production then one for development and testing.There is a fresh database for testing for every test run.

Installing Rails:
1)First Ruby has to be installed.Then install the ruby gems using the command..
               sudo install rubygems
2)Then install the rails gem using
               sudo  gem  install rails--include-dependencies
Updating Rails:
Give
                rails update
Installation verification:
Give "rails demo".A demo project is created.Then give it as "http://localhost:3000".It should give the Welcome aboard or congratulations message.

Model View Controller Pattern:Model stands for all the business logic in the application involving the database.This subsystem is implemented in ActiveRecord library which provides an interface and binding between the tables in a relational database and the Ruby program code that manipulates database records. Ruby method names are automatically generated from the field names of database tables, and so on.Controller is what controls the flow.This subsystem is implemented in ActionController which is a data broker sitting between ActiveRecord and ActionView.And view is how the data is displayed on the screen.This subsystem is implemented in ActionView library which is an Embedded Ruby (ERb) based system for defining presentation templates for data presentation. Every Web connection to a Rails application results in the displaying of a view.The request is first sent to the controller and it redirects to the corresponding model which is then displayed on the screen.

The Architecture:
Rails Framework

Directory Structure:
          You can access the directory structure of the demo project that  you created by using
                        C:\ruby\> cd demo

              C:\ruby\demo> dir

The models views and the controllers exist in the app folder in the structure.The config file has the route file which is used for routing r redirecting the file.This is the directory structure:
demo/
..../app
......../controller
......../helpers
......../models
......../views
............../layouts
..../components
..../config
..../db
..../doc
..../lib
..../log
..../public
..../script
..../test
..../tmp
..../vendor
README
Rakefile



No comments:

Post a Comment