Over a million developers have joined DZone.

Rails Generator Syntax

// 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

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}