Search This Blog

Showing posts with label Ruby on Rails. Show all posts
Showing posts with label Ruby on Rails. Show all posts

Saturday, May 8, 2010

First Ruby on Rails (ROR)

Installation 


http://www.ruby-lang.org/en/downloads/

Download ruby package
$ tar -xvzf ruby-1.9.1-p376.tar.gz
$ cd ruby-1.9.1-p376/
$ . /configure
$ make
$ make install

download rubygems
$ tar -xvzf rubygems-1.3.6.tgz
$ cd rubygems-1.3.6/

$ ruby setup.rb
$ gem install rails

Creating first project 
$ rails firstpro

Above step will create project with following dir structure

drwxr-xr-x 6 gt gt  4096 2010-05-08 15:42 app
drwxr-xr-x 5 gt gt  4096 2010-05-08 15:42 config
drwxr-xr-x 2 gt gt  4096 2010-05-08 15:42 db
drwxr-xr-x 2 gt gt  4096 2010-05-08 15:42 doc
drwxr-xr-x 3 gt gt  4096 2010-05-08 15:42 lib
drwxr-xr-x 2 gt gt  4096 2010-05-08 15:42 log
drwxr-xr-x 3 gt gt  4096 2010-05-08 15:46 nbproject
drwxr-xr-x 5 gt gt  4096 2010-05-08 15:42 public
-rw-r--r-- 1 gt gt   307 2010-05-08 15:42 Rakefile
-rw-r--r-- 1 gt gt 10011 2010-05-08 15:42 README
drwxr-xr-x 3 gt gt  4096 2010-05-08 15:42 script
drwxr-xr-x 7 gt gt  4096 2010-05-08 15:42 test
drwxr-xr-x 6 gt gt  4096 2010-05-08 15:42 tmp
drwxr-xr-x 3 gt gt  4096 2010-05-08 15:42 vendor


ROR works in MVC architecture put your files inside apps accordingly 

drwxr-xr-x 2 gt gt 4096 2010-05-08 15:42 controllers
drwxr-xr-x 2 gt gt 4096 2010-05-08 15:42 helpers
drwxr-xr-x 2 gt gt 4096 2010-05-08 15:42 models
drwxr-xr-x 3 gt gt 4096 2010-05-08 15:42 views

use the script inside the script folder to perform rails operations 

rwxr-xr-x 1 gt gt  159 2010-05-08 15:42 about
-rwxr-xr-x 1 gt gt  104 2010-05-08 15:42 console
-rwxr-xr-x 1 gt gt  106 2010-05-08 15:42 dbconsole
-rwxr-xr-x 1 gt gt  104 2010-05-08 15:42 destroy
-rwxr-xr-x 1 gt gt  105 2010-05-08 15:42 generate
drwxr-xr-x 2 gt gt 4096 2010-05-08 15:42 performance
-rwxr-xr-x 1 gt gt  103 2010-05-08 15:42 plugin
-rwxr-xr-x 1 gt gt  103 2010-05-08 15:42 runner
-rwxr-xr-x 1 gt gt  103 2010-05-08 15:42 server

To Run server 
$ script/server 

=> Booting WEBrick
=> Rails 2.3.5 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
[2010-05-08 15:43:20] INFO  WEBrick 1.3.1
[2010-05-08 15:43:20] INFO  ruby 1.9.1 (2009-12-07) [i686-linux]
[2010-05-08 15:43:25] INFO  WEBrick::HTTPServer#start: pid=31445 port=3000

Check in your browser for the link below (Output)

http://localhost:3000

if you get ROR page then your ROR is working successfully else check the steps above 

Give a try :)

In my next post we can see how to create simple ROR application