Ask A Question

Notifications

You’re not receiving notifications from this thread.

How do I share my master.key with capistrano deployment

René Rodriguez Clavijo asked in Rails

After following the guide Deploy Ruby on Rails on ubuntu 18.04 I still have several problems with the app. Shows me the same error when rails can't find master.key and I'm not sure how .rb-envs works or how to share my master.key with deployment.
This is the error:

DEBUG [30e1aa26]       NoMethodError: undefined method `[]' for nil:NilClass
DEBUG [30e1aa26]       /home/ubuntu/oficinas/releases/20210907184538/config/database.yml:16:in `<main>'

and this is my database.yml

default: &default
  adapter: postgresql
  host: 127.0.0.1 #localhost
  port: 5432
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  timeout: 5000

development:
  <<: *default
  username: <%= Rails.application.credentials.db[:nombre_usuario] %>
  password: <%= Rails.application.credentials.db[:password] %>
  database: oficinas-desarrollo

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: oficinas-pruebas

production:
  <<: *default
  username: <%= Rails.application.credentials.db_produccion[:nombre_usuario] %>
  password: <%= Rails.application.credentials.db_produccion[:password] %>
  database: oficinas-produccion
Reply

In app-name/shared/config/ you can add your master.key

Then in Capistrano's deploy.rb add:
append :linked_files, "config/master.key"

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 87,563+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.