如何在heroku评论应用程序中将RAILS_ENV设置为暂存?

时间:2016-08-26 22:14:16

标签: ruby-on-rails heroku

现在,在Rails 5 heroku评论应用程序中,RAILS_ENV设置为" production"在配置变量部分。如果我将值更改为" staging"并尝试在heroku评论应用程序上运行 rails console ,它崩溃时出现错误输出:

config.eager_load is set to nil. Please update your config/environments/*.rb files accordingly:

* development - set it to false
  * test - set it to false (unless you use a tool that preloads your test environment)
  * production - set it to true

    /app/vendor/bundle/ruby/2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:498:in `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError)

      config.secret_key = 'xxx'

    Please ensure you restarted your application after installing Devise or setting the key.
        from /app/vendor/bundle/ruby/2.3.0/gems/devise-4.1.1/lib/devise/rails/routes.rb:226:in `devise_for'
        from /app/config/routes.rb:6:in `block in <top (required)>'
        from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `instance_exec'
        from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:389:in `eval_block'
        from /app/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0.1/lib/action_dispatch/routing/route_set.rb:371:in `draw'
        from /app/config/routes.rb:1:in `<top (required)>'

将RAILS_ENV设置为&#34; staging&#34;意味着我必须创建一个 config / staging.rb 文件,因为Rails会从那里推断出环境设置?

1 个答案:

答案 0 :(得分:1)

事实证明,需要做三件事:

我必须在heroku评论应用的Heroku配置变量部分中将 RAILS_ENV 设置为 staging 。我创建了一个config / environments / staging.rb文件,它是config / environments / development.rb的副本。我还必须使用 bundle exec rake secret 添加生成密钥,并将该值复制并粘贴到

的嵌套yaml键下的config / secrets.yml中
staging:
  secret_key_base: 12345xxy