DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Rails Generator Syntax

10.08.2006
| 87090 views |
  • submit to reddit
        // generate application
rails projectname

// generate migration.
ruby script/generate migration migration_name
ruby script/generate migration add_price

// generate model
// we can give a list of columns and types
// :string, :text, :integer, :decimal, :float, :date, ...
ruby script/generate model model_name
ruby script/generate model user name:string hashed_password:string salt:string

// generate controller
ruby script/generate controller controller_name method_name(s)
ruby script/generate controller store index

// generate scaffold
ruby script/generate scaffold model_name controller_name
ruby script/generate scaffold product admin