ruby on rails: basic commands

Posted on December 23, 2009 at 4:19 am by waqas 1 Comment
This is a very basic guide for those who are interested in learning ruby on rails. I assume you have already installed ruby on rails and have basic knowledge. Many beginners using ruby on rails will not use any IDE, rather they will use command line if installed on MAC or linux. So here I will list seven important commands which you really need to know inside out and are used throughout the development of a project. I will use Demo as project name and users (model) as a table in the database.

rails Demo

The above command will create a rails app called demo with all the good things you need.

ruby script/generate scaffold User name:string email:string active:boolean

The above command will create a sacffold called User with CRDU functions.

rake db:migrate

The above command will create the table called users in the database.

ruby script/generate controller <name>

The above command is used to generate a new controller.

ruby script/generate model <name>

The above command will generate a new model as well as a migration file.

ruby script/generate migration <name>

The above command can be used to generate a new migration file.

ruby script/server

And finally the above command is executed to start the WEBRICK server.

There are many more commands that are used when working with ruby on rails, but the seven listed above are basic and common that everyone needs to know!

1 Comment on "ruby on rails: basic commands"

  1. rubydev · October 6, 2010 at 9:23 am ·

    nice quick guide for new starters!

Leave a comment