Ruby on rails Rails如何在开发模式和生产模式之间切换?
如何在Rails中在开发模式和生产模式之间切换Ruby on rails Rails如何在开发模式和生产模式之间切换?,ruby-on-rails,ruby,ruby-on-rails-4,Ruby On Rails,Ruby,Ruby On Rails 4,如何在Rails中在开发模式和生产模式之间切换 如何将数据库部署到生产环境中?使用-e选项启动服务器 rails server -e production 并且您不能部署数据库。您需要迁移才能在生产环境中运行 要在开发模式下启动服务器,您只需运行rails s即可在开发模式下启动应用程序和数据库 要在生产模式下启动服务器,您需要使用bundle exec rake db:migrate RAILS_ENV=production迁移数据库,然后使用RAILS s-e production或RAI
如何将数据库部署到生产环境中?使用
-e
选项启动服务器
rails server -e production
并且您不能部署数据库。您需要迁移才能在生产环境中运行 要在开发模式下启动服务器,您只需运行
rails s
即可在开发模式下启动应用程序和数据库
要在生产模式下启动服务器,您需要使用
bundle exec rake db:migrate RAILS_ENV=production
迁移数据库,然后使用RAILS s-e production
或RAILS_ENV=production RAILS s s
启动服务器,如果您使用的是RAILS 4.2,那么您必须知道RAILS使用的是“spring”让它更快。因此,在这种情况下,您可以使用以下命令:
bin/spring stop
bin/spring start
为了发展,我们刚刚开始
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\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
此外,如果要停止弹簧或启动弹簧,请使用以下命令:
bin/spring stop
bin/spring start
在rails 5中+
后藤
你可以找到下面这行
environment ENV.fetch("RAILS_ENV") { "development" }
如果要在生产环境中运行服务器并在控制台中启用日志,请将“开发”更改为“生产”:
rails s -C --log-to-stdout -e production
bundle exec rake db:migrate RAILS_ENV=production
RAILS_ENV=production rake db:migrate
也许您还没有创建数据库,所以您必须运行RAILS_ENV=production rake db:create
和RAILS_ENV=production rake db:schema:load
,然后您的生产数据库将被设置。rake db:migrateRAILS\u ENV=“production”在RAILS 6中,如果在本地使用puma,请确保config.public\u file\u server.enabled=true
。。。但是现在我遇到了一个问题,没有加载任何样式等..:(这可能是一个与这个问题不同的资产问题。试着用谷歌搜索一下,这类问题有很多问题/答案issue@FelixtryRAILS\u ENV=生产rake资产:预编译