Felix Felix - 2 years ago 93
Ruby Question

Rails how to switch between dev and production mode?

How can I switch in Rails between the dev mode and the production mode?

and how can I deploy the database to production?

Answer Source

If you are using Rails 4.2 then you must know rails uses "spring" to make it faster. So in that case you can use following commands:

For Development just run

Rails 4.2
    bin\rails s
   rails s

For Production just run

Rails 4.2
    bin\rails s -e production
    rails s -e production

To setup production database if database in production does not exist then run

Rails 4.2
    bin/rake db:create db:migrate RAILS_ENV=production
    rake db:create db:migrate RAILS_ENV=production
    bundle exec rake db:create db:migrate RAILS_ENV=production

If DB already exists the:

Rails 4.2
  bin/rake db:migrate RAILS_ENV=production
  rake db:migrate RAILS_ENV=production
  bundle exec rake db:migrate RAILS_ENV=production

Also if you want to stop spring or start spring then use following commands:

 bin/spring stop
 bin/spring start
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download