Thursday, April 1, 2010

RUBY ON RAILS


HI I have done this ROR as IEEE paper and I used for my ENGLISH LAB for technical presentation I just share this with all of you...........

RUBY ON RAILS

Ruby on Rails is often called as RoR or simply Rails. RoR developers are RAILS core team .It is a cross-platform programming language .It holds the MIT license. Ruby on Rails was extracted by David Heinemeier Hansson from his work on Basecamp a project management tool by 37 signals Heinemeier Hansson first released Rails as open source in July 2004.

TECHNICAL ASPECTS

Similar to other web frameworks RoR uses MVC, MODEL-VIEW-CONTROLLER for developing a web application. It also uses CONVENTION OVER CONFIGURATION,which is a software that reduces the decision that the developers need to take, it also provides the simplicity for web developers.

It effectively makes use of DRY code concepts in it programming techniques .
DON’T REPEAT YOURSELF means the information stored in a single place .and it can be retrieved whenever needed.

It popularised the scaffolding to all other frameworks such as ASP.NET,CAKEPHP,DJANGO etc..,SCAFFOLDING is the meta-programming which helps programmer to just specify how the database to be used, for example CREATE,DELETE,READ etc..,ROR uses a library called WEBrick which provides a HTTP web server .It developed by Masayoshi Takahashi and Yuuzou Gotou along with other developers in open source environment .It used in Ruby on Rails to check the programs during developing session .But it also supports other web servers such as Apache, Lighttpd, Abyss but it come along with WEBrick.It makes extensive use of Javascript and AJAX.Since version 2.0 it produces default output of HTML and XML formats.
MODEL-VIEW-CONTROLLER

MODEL-VIEW-CONTROLLER is used for developing a web application in RoR It is an architectural pattern used in deploying applications.The model is the domain-specific representation of the data upon which the application operates
It has three main parts:
View: It provides a model for interaction for the users; multiple users are allowed to view a single model.
Controller: It receives the input from the user and access the model objects.
Model: It is the place where the Model objects are placed.
The MVC is a combination of view-controller-model .Usually Controller get input from GET or POST typically used in FORMS from View. It decides what to access in the Model.

CONVENTION OVER CONFIGURATION

Convention over configuration is a software used to help the developer by reducing the decision that the developer takes during the program. It provides efficiency and simplicity for the developers.
A Web application is consist of many parts, and you can go crazy about all the parts. Configuration has taken over the web application frameworks so that even a simple task such as applying 'compulsory field' validation for that just requires one field entries in an XML file. We take one small example. You have a variable called video in a program, and you have a column called movies in a database table. The computer program fetches data from the movies table and this data stores in the video variable. The program displays the video on a Web page.

DON’T REPEAT YOURSELF

DON’T REPEAT YOURSELF shortly known as DRY code,it stores the information in a single place so programmer need not to repeat the code instead he can retrieve it effectively.
DRY principle is also referred to as "Once and Only Once," the DRY principle states that you should only need to express a particular piece of information once in a system. If you applied properly then reduces the duplication of tasks within a project. Duplication is usually unnecessary, especially in dynamic languages like Ruby. Duplication within a project, leads to difficulty in modification and maintenance and inconsistency.
One of the easiest ways to get a feel for metaprogramming is to look for repeated code. Repeated code can be factored into functions and redundant functions can often be factored through the use of meta programming.

WEB SERVERS

We need web servers mainly used for sending files to our client as well we want to receive them back to us. RoR supports various web-servers such as WEBricks, APACHE, Lighttpd, ABYSS, though We Bricks comes along with the RUBY ON RAILS, during installation. WEBricks need not want any special configuration as it is in built. But on using any other web-servers we need to go for configuration.

INSTALLATION ON UBUNTU


First we need to install Ruby and irb (Interactive ruby shell) and we’ll add ri and rdoc. The recommended Ruby version for rails is 2.0
Open your terminal and type

sudo apt-get install ruby irb ri rdoc ruby1.8-dev2.2
Then we need to install RubyGems. We are going to install RubyGems with the following command
sudo apt-get install rubygems
Then we’ll update RubyGems with the following command
sudo gem update --systemNow
Now we will install rails with command
sudo gem install rails --include-dependencies
That’s it You have successfully installed Ruby on Rails.
Now we need to install MySQL
sudo apt-get install mysql-server mysql-client

We need to make some of the libraries to go with RUBY
by just giving the following command

sudo apt-get install libmysql-ruby

We can use any text editor for our convince.
Similarly all the web browsers are supported. We can make use which suits our need.

WEB-SERVER, WEBrick is the built in web-server so no need to install it separately. But if we want to use APACHE we can use the command:


sudo apt-get install apache2 apache2-mpm-prefork apache2-prefork-dev



We can also install Lighttpd by


sudo apt-get install lighttpd libfcgi-ruby2

getting started


To start the Rails open the Terminal and type

$mkdir stites

This creates a directory to work with Rails.

$rails my_app

Type this inside the sites folder. This will create the rails applications.

To start the default WEBrick server just use following codes:

$cd /home/myuser/www/mynewapp

$ruby script/server

=> Booting WEBrick...

=> Rails 2.1.0 application started on http://0.0.0.0:3000

=> Ctrl-C to shutdown server; call with --help for options

[2008-07-28 04:39:17] INFO WEBrick 1.3.1

[2008-07-28 04:39:17] INFO ruby 1.8.6 (2007-09-24)

[2008-07-28 04:39:17] INFO WEBrick::HTTPServer#start: pid=6860 port=3000

This simply boots the WEBrick.

RAILS have an extension .rb.

how rails works

RAILS generally works as routes, generally it will be in the sequence

:server/:controller/:action:/id

-here server, controller, action and id gets replaced and it will always be in the same consequence.

For example:

http://localhost/say/hello/50;

in this localhost is the server,say is the controller, action is the hello and id is the 50.

Just mentioning the server we get the server page

http://localhost/

This page will be useful in working with ruby on rails and also confirms that ruby on rails is installed

RAILS IN WEB 2.0

As WEB 2.0 created the highly interactive web-applications, RAILS provides the broader and simple approach in creating more dynamic webpages by working along with AJAX, javascript

Rails have a simple, consistent model for how it implements Ajax operations. Once the browser has rendered and displayed the initial web page, different user actions cause it to display a new web page or trigger an Ajax operation:

A trigger action occurs. This could be the user clicking on a button or link, the user making changes to the data on a form or in a field, or just a periodic trigger (based on a timer).

Data associated with the trigger (a field or an entire form) is sent asynchronously to an action handler on the server via XMLHttpRequest.

The server-side action handler takes some action (that's why it is an action handler) based on the data, and returns an HTML fragment as its response.

The client-side JavaScript (created automatically by Rails) receives the HTML fragment and uses it to update a specified part of the current page's HTML, often the content of a

tag.

An Ajax request to the server can also return any arbitrary data The real beauty is how easy Rails makes it to implement all of this in your web application. Thus the RAILS works with the AJAX for WEB 2.0 environment.

RAILS IN POPULAR WEBSITES

Rails is been in used in various web sites but lets see some

of popular sites TWITTER, YELLOWPAGES, XING.

A) TWITTER:

Twitter is a free social networking and micro blogging service that enables its users to send and read messages known as tweets. Its framework is developed by RUBY ON RAILS. It is one of the highly interactive webpage in the WEB 2.0 era with various options such as SMS,PHONE SERVICE PROVIDER.

B) YELLOWPAGES:

Yellow page is an Internet web site operated by YELLOWPAGES.COM LLC, a wholly owned subsidiary of AT&T The Company has been recognized as one of the top sources of online advertisements.

C) XING:

XING is a social software platform for enabling a small-world network for professionals. It is used by people from over 200 countries. Available languages include English, German, Spanish, Portuguese, Italian, French, Dutch, Chinese, Finnish, Swedish, Korean, Japanese, Russian, Polish, Turkish and Hungarian.


Ruby on Rails is a fast emerging web framework that already created a big anticipation among the web developers and programmers.It gives more simple and efficient way of developing a dynamic web applications,as a engineers it is necessary to identify the functions and various options that the RoR provides.

2 comments:

  1. great work friend. can you explain me about python programming? strating from introduction, comparisons with other languages, its specifications and other key features if you can?
    by,Anand.c

    ReplyDelete
  2. HI MR.SATHISH I NEED THIS ARTICLE TO BE A PART OF MY WEBSITE.SO CAN U PROVIDE THE COPY RIGHTS???

    ReplyDelete