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
Topics:

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

{{ parent.tldr }}

{{ parent.urlSource.name }}