Setting up a new project using rails --- blog example
#create a new model
bin/rails generate model Article title:string text:text
bin/rails generate model Comment commenter:string body:text article:references
- it creates a migration in db/migrate
#create a controller
bin/rails generate controller Comments
#run migration
bin/rake db:migrate
- it will create the db in the migration files (tables, rows etc)
*Because you're working in the development environment by default, this
command will apply to the database defined in the development section of your
config/database.yml file. If you would like to execute migrations in another
environment, for instance in production, you must explicitly pass it when
invoking the command: bin/rake db:migrate RAILS_ENV=production.*
#run rails project
bin/rails s -b 0.0.0.0