ruby-on-rails - 在本地生产环境中运行Rails服务器(InvalidMessage错误)

标签 ruby-on-rails production

我正在运行Ruby 2.5.1和Rails 5.2.0。我运行了rails s -e production,它给出了这个错误:

/home/roy/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:206:in `rescue in_decrypt': ActiveSupport::MessageEncryptor::InvalidMessage
(ActiveSupport::MessageEncryptor::InvalidMessage)


如何正确执行此操作?



编辑:
每当我尝试使用来编辑凭据文件时,都会出现相同的错误

EDITOR="nano --wait" bin/rails credentials:edit


我也意识到我还没有创建生产数据库,所以我尝试使用

RAILS_ENV=production bundle exec rails db:reset


(我知道db:reset有点多余,但是在尝试创建,迁移和设置服务器种子时应该可以使用)

可悲的是,我得到了同样的错误(InvalidMessage错误)

Unsupported rails environment for compass
rake aborted!
ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
/home/roy/apps/myappname/config/environment.rb:5:in `<main>'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'

Caused by:
OpenSSL::Cipher::CipherError: 
/home/roy/apps/myappname/config/environment.rb:5:in `<main>'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `load'
/home/roy/.rbenv/versions/2.5.1/bin/bundle:23:in `<main>'
Tasks: TOP => db:create => db:load_config => environment

最佳答案

好吧,我终于开始工作了。

我只是删除了master.keycredentials.yml.enc文件,然后运行

bin/rails credentials:edit


哪个创建了新文件。之后,一切正常。

我真的不明白为什么它起作用。谁能对此做出很好的解释?

关于ruby-on-rails - 在本地生产环境中运行Rails服务器(InvalidMessage错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50102639/

相关文章:

ruby-on-rails - 使用FactoryGirl,如何将accepts_nested_attributes_for 子属性插入到我正在创建的对象中?

ruby-on-rails - 如何在生产日志文件中禁用 Rails 路由错误堆栈跟踪打印?

sql-server - 用于在 Amazon EC2 微型实例上进行生产的 SQL Server Express 2008 R2

ruby-on-rails-3.1 - wicked_pdf + rails 的 Assets 管道 + 生产中的 sass 导入

ruby-on-rails - Mongoid 4 : like query on integer column

ruby-on-rails - 更改列名称 Rails

python - 准备用于生产的 Pyramid 应用程序

ruby-on-rails - 在生产中运行我的应用程序时缺少 secret token 、 secret keystore

mysql - 何时在 Rails 中的表中添加哪些索引

ruby-on-rails - Rails 测试在明显存在的情况下无法找到路线?