Rails 如何在开发模式和生产模式之间切换? [英] Rails how to switch between dev and production mode?

查看:57
本文介绍了Rails 如何在开发模式和生产模式之间切换?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在开发模式和生产模式之间切换 Rails?

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

以及如何将数据库部署到生产环境中?

and how can I deploy the database to production?

推荐答案

如果您使用的是 Rails 4.2,那么您必须知道 rails 使用spring"来使其更快.因此,在这种情况下,您可以使用以下命令:

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:

对于开发只需运行

Rails 4.2
    bin\rails s
Otherwise
   rails s

对于生产只需运行

Rails 4.2
    bin\rails s -e production
Otherwise    
    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
Otherwise
    rake db:create db:migrate RAILS_ENV=production
    bundle exec rake db:create db:migrate RAILS_ENV=production

如果数据库已经存在:

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

此外,如果您想停止 spring 或启动 spring,请使用以下命令:

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

 bin/spring stop
 bin/spring start

这篇关于Rails 如何在开发模式和生产模式之间切换?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆