我如何在Rails中切换开发模式和生产模式?
我要如何将数据库部署到生产环境?
我如何在Rails中切换开发模式和生产模式?
我要如何将数据库部署到生产环境?
Rails 4.2
bin\rails s
Otherwise
rails s
要进行生产,请运行
Rails 4.2
bin\rails s -e production
Otherwise
rails s -e production
安装生产数据库 如果生产中不存在数据库,则运行
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,请使用以下命令:
bin/spring stop
bin/spring start
使用-e
选项启动服务器。
rails server -e production
你不能直接部署数据库,需要进行迁移以在生产环境中运行。
要在开发模式下启动您的服务器,您只需要运行rails s
,它将同时启动您的应用程序和数据库。
要在生产模式下启动您的服务器,您需要使用bundle exec rake db:migrate RAILS_ENV=production
迁移您的数据库,然后使用rails s -e production
或RAILS_ENV=production rails s
启动您的服务器。
RAILS_ENV=production rake assets:precompile
。 - Mohammad AbuShadyconfig/puma.rb
您可以在下面找到这行代码
environment ENV.fetch("RAILS_ENV") { "development" }
将"development"改为"production"
如果您想在生产环境中运行服务器并在控制台中启用日志记录,则可以运行以下命令:
rails s -C --log-to-stdout -e production
bundle exec rake db:migrate RAILS_ENV=production
- apneadivingRAILS_ENV=production rake db:migrate
可能你还没有创建数据库,所以你需要运行RAILS_ENV=production rake db:create
和RAILS_ENV=production rake db:schema:load
来设置你的生产数据库。 - edariedlconfig.public_file_server.enabled = true
。 - cdmo