Rails Migrations Cheatsheet - Paprikas/rails_cheat_sheet GitHub Wiki
By generating Model
bin/rails generate model user pseudo:string:uniq
bin/rails generate model user pseudo:string:index
bin/rails generate model user pseudo:string{30}
bin/rails generate model user pseudo:string{30}:uniq
bin/rails generate model product 'price:decimal{10,2}'
bin/rails generate model product supplier:references
bin/rails generate model product supplier:references{polymorphic}
bin/rails generate model product supplier:references{polymorphic}:index
As a special case, specifying 'password:digest' will generate a password_digest field of string type, and configure your generated model and tests for use with Active Model has_secure_password (assuming the default ORM and test framework are being used).
bin/rails generate model user password:digest
If you require a token
string column for use with has_secure_token, you can specify auth_token:token
bin/rails generate model user auth_token:token