How can I use Rails 5.2 credentials in capistrano&

2019-05-01 17:28发布

问题:

I've just updated my Rails app to 5.2, and configured it to use the new config/credentials.yml.enc file.

When I try to deploy, I get this error:

NameError: uninitialized constant Rails
/Users/me/Documents/project/config/deploy.rb:27:in `<top (required)>'

That's pointing to this line in my config/deploy.rb file:

set :rollbar_token, Rails.application.credentials[:rollbar_token]

So it appears that while capistrano is running, it doesn't have access to Rails.application.credentials.

How are you all handling this? I've got some ideas...

  • Set this one variable as an ENV variable
    • I don't love how this separates/customizes this one setting
  • Somehow make it so capistrano has access to Rails.application.credentials
    • I don't know if this is a good idea or if there are other things I need to be aware of if I go this route
  • Remove deploy tracking in rollbar