Getting Started With Rails Project Using Scaffold

Hai friends,

Today i learned from raji akka “How to create a rails project using scaffold”

Lets see the simple procedures:

Open your terminal and follow the following lines,

rails new contact -d mysql

Here, the rails project name is “contact”. Now we must go into the project directory.

cd contact

We MySQL instead of the shipped Sqlite3 database,Open the following ‘yml’ file and insert our mysql password in the 3 columns (i.e development,test,production) )

gedit config/database.yml

Now, we are in the main part of the creating rails project using sacffold. Here the ‘User’ is thr DB table name. Note the ‘U’ . We must set the table’s starting letter in ‘Caps’ and after finishing all procedures, in browser we call it, as “users” (Note: All letters in small and called is pulural)

rails generate scaffold User name:string phone_number:integer mailid:string age:integer sex:string town:string

(Now in mysql DB, some databases were automatically created like “contact_development and contact_test”)

rake db:create

rake db:migrate

(Starting the rails server)

rails s

Now we can add the contacts in the web browser. After starting the rails server, in the url add the “users” (i.e) It is the name of the DB table name and it is in the plural form.

here add your contacts. 🙂 that’s all. 😉

Now, we are going to see the mysql DB side.(open another terminal and use it)

mysql -u root -p (Entering in the mysql DB. Here it asks the mysql password)

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| contact_development |
| contact_test        |
4 rows in set (0.00 sec)

mysql> use suresh_development;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
mysql> show tables;
| Tables_in_suresh_development |
| schema_migrations            |
| users                        |
2 rows in set (0.00 sec)

mysql> select * from users;
Empty set (0.00 sec)

(Now we can see only the empty )

(Now open the and add the new contacts)

mysql> select * from users;
| id | name       | phone_number | mailid                 | age  | sex  | town    | created_at          | updated_at          |
|  1 | Tha.Suresh |   2147483647 | |   22 | male | chennai | 2011-01-20 07:31:49 | 2011-01-20 07:36:41 |
1 row in set (0.00 sec)

Some ‘browser and mysql’ Db snaps:

Rails welcome page

Addind contacts

mysql DB snap


2 thoughts on “Getting Started With Rails Project Using Scaffold

  1. Pingback: Install Rails 3 on Fedora 14 | my linux world

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s