ruby-on-rails - 无法编辑 Rails 凭据 Rails 5.2

标签 ruby-on-rails ruby-on-rails-5 ruby-on-rails-5.2

我正在开发 Rails 5.2 应用程序,并且已经安装并设置了 active_storage,但是,我似乎无法编辑或显示 rails 凭据。

这是错误的输出

ben@ben-VirtualBox:~/Desktop/benbagley$ EDITOR="atom --wait" rails credentials:edit
Traceback (most recent call last):
    38: from bin/rails:3:in `<main>'
    37: from bin/rails:3:in `load'
    36: from /home/ben/Desktop/benbagley/bin/spring:15:in `<top (required)>'
    35: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
    34: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/2.5.0/rubygems/core_ext/kernel_require.rb:70:in `require'
    33: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `<top (required)>'
    32: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/binstub.rb:31:in `load'
    31: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/bin/spring:49:in `<top (required)>'
    30: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client.rb:30:in `run'
    29: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/command.rb:7:in `call'
    28: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `call'
    27: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/spring-2.0.2/lib/spring/client/rails.rb:28:in `load'
    26: from /home/ben/Desktop/benbagley/bin/rails:9:in `<top (required)>'
    25: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `require'
    24: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:249:in `load_dependency'
    23: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/dependencies.rb:283:in `block in require'
    22: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:29:in `require'
    21: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:20:in `require_with_bootsnap_lfi'
    20: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/loaded_features_index.rb:65:in `register'
    19: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `block in require_with_bootsnap_lfi'
    18: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/bootsnap-1.3.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require'
    17: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands.rb:18:in `<main>'
    16: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command.rb:46:in `invoke'
    15: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/base.rb:65:in `perform'
    14: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor.rb:387:in `dispatch'
    13: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/invocation.rb:126:in `invoke_command'
    12: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/thor-0.20.0/lib/thor/command.rb:27:in `run'
    11: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/credentials/credentials_command.rb:26:in `edit'
    10: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/command/helpers/editor.rb:26:in `catch_editing_exceptions'
     9: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/credentials/credentials_command.rb:27:in `block in edit'
     8: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/railties-5.2.0/lib/rails/commands/credentials/credentials_command.rb:50:in `change_credentials_in_system_editor'
     7: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:54:in `change'
     6: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_configuration.rb:21:in `read'
     5: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:42:in `read'
     4: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/encrypted_file.rb:79:in `decrypt'
     3: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/messages/rotator.rb:21:in `decrypt_and_verify'
     2: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:157:in `decrypt_and_verify'
     1: from /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activesupport-5.2.0/lib/active_support/message_encryptor.rb:183:in `_decrypt'
/home/ben/.rbenv/versions/2.5.0/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)

但是,当我生成一个新应用程序时,我可以编辑和显示凭据。所以不确定这个应用程序的问题,因为我没有更改主 key 。

编辑::

我也得到
ben@ben-VirtualBox:~/Desktop/benbagley$ rails s
=> Booting Puma
=> Rails 5.2.0 application starting in development 
=> Run `rails server -h` for more startup options
Puma starting in single mode...
* Version 3.11.4 (ruby 2.5.0-p0), codename: Love Song
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://0.0.0.0:3000
Use Ctrl-C to stop
Started GET "/" for 127.0.0.1 at 2018-05-20 14:39:37 +0100
   (5.1ms)  SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
  ↳ /home/ben/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/activerecord-5.2.0/lib/active_record/log_subscriber.rb:98
Processing by PagesController#welcome as HTML
  Rendering pages/welcome.html.erb within layouts/application
  Rendered pages/welcome.html.erb within layouts/application (1.0ms)
  Rendered layouts/_navigation.html.erb (0.6ms)
  Rendered layouts/_footer.html.erb (0.3ms)
Completed 200 OK in 1149ms (Views: 1136.3ms | ActiveRecord: 0.0ms)


Started GET "/works" for 127.0.0.1 at 2018-05-20 14:39:41 +0100
Processing by WorksController#index as HTML
  Rendering works/index.html.erb within layouts/application
  Work Load (1.7ms)  SELECT "works".* FROM "works"
  ↳ app/views/works/index.html.erb:5
  ActiveStorage::Attachment Load (1.7ms)  SELECT  "active_storage_attachments".* FROM "active_storage_attachments" WHERE "active_storage_attachments"."record_id" = $1 AND "active_storage_attachments"."record_type" = $2 AND "active_storage_attachments"."name" = $3 LIMIT $4  [["record_id", 2], ["record_type", "Work"], ["name", "header_image"], ["LIMIT", 1]]
  ↳ app/views/works/index.html.erb:7
  Rendered works/index.html.erb within layouts/application (63.0ms)
Completed 500 Internal Server Error in 71ms (ActiveRecord: 15.9ms)



ActionView::Template::Error (ActiveSupport::MessageEncryptor::InvalidMessage):
    4: 
    5:     <% @works.each do |work| %>
    6:     <section class="max-w-md w-full lg:flex mb-2 shadow-md">
    7:       <section class="h-48 lg:h-auto lg:w-64 flex-none bg-cover rounded-t lg:rounded-t-none lg:rounded-l text-center overflow-hidden" style="background-image: url('<%= polymorphic_url work.header_image %>'); background-position: 50%; background-repeat: no-repeat;" title="<%= work.title %>">
    8:       </section>
    9:       <section class="border-r border-b border-l border-champagne-dark lg:border-l-0 lg:border-t bg-champagne-dark rounded-b lg:rounded-b-none lg:rounded-r p-4 flex flex-col justify-between leading-normal">
   10:         <section class="mb-6">

(erb):12:in `<main>'
app/views/works/index.html.erb:7:in `block in _app_views_works_index_html_erb__3122246537996604426_69953460278620'
app/views/works/index.html.erb:5:in `_app_views_works_index_html_erb__3122246537996604426_69953460278620'
^C- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2018-05-20 14:39:55 +0100 ===
- Goodbye!
Exiting

最佳答案

注释您使用凭据的行并运行 EDITOR="atom --wait" rails credentials:edit (并在编辑后取消注释)。如果这不起作用,请删除credentials.yml.enc 并重试。

关于ruby-on-rails - 无法编辑 Rails 凭据 Rails 5.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50435193/

相关文章:

ruby-on-rails - 处理旧数据库中的列名 'hash'

ruby-on-rails - 使用耐嚼的 gem 无法突出显示关系的搜索结果

ruby-on-rails - 如何在 :if validation 中使用枚举值

ruby-on-rails - Rails ActionMailer 使用 API 方法而不是 SMTP - SendGrid

ruby-on-rails - rails : During asset precompile throws error key must be 16 bytes

ruby-on-rails-5 - 使用 STI 时,Rails 5.0 不获取多态关联

javascript - 在 Rails 应用程序中加载自定义 javascript 文件

php - 需要 Web 应用程序的书籍建议

mysql - ruby on rails,嵌套属性,采用最高属性

ruby-on-rails - Rails、Postgres 仅显示所有搜索参数中存在的项目