Rails Basic Commands
Rails Basic Commands
Active Record Migrations:
rake db:create
rake db:migrate
# rails generate migration AddPartNumberToProducts part_number:string
# rails generate migration CreateProducts name:string part_number:string
# rails generate migration AddUserRefToProducts user:references
# rails g migration CreateJoinTableCustomerProduct customer product
# rails generate model Product name:string description:text
Rolling Back:
rails db:rollback
rails db:rollback STEP=3
rails db:migrate:redo STEP=3
Controller Generate:
rails g controller controller_name action_name
Model Generate:
rails g model model_name column_name:column_type
example: rails g model student name:string course_id:integer
Seed:
rake db:seed
Routes Check:
rake routes
rake routes | grep users
Active admin:
rails generate active_admin:install
rails generate active_admin:resource [MyModelName]
example: rails generate active_admin:resource user