Rails.application.credentials.dig is not working

Viewed 2886

This is my credentials.yml

development:
  a:
    b:
      c:
        d: http://test.com
> Rails.application.credentials.dig(Rails.env.to_sym, :a,:b,:c,:d) + "service"
undefined method `+' for nil:NilClass (NoMethodError)

Anyone can help me to fix it?

1 Answers

You cannot use plain text credentials if you're using Rails 5.2 or newer.

There's only credentials.yml.enc instead of credentials.yml

credentials.yml.enc is an encrypted file which store the credentials.

To add credentials, run EDITOR=vim rails credentials:edit and then add your credentials to editor.

After they are saved, Rails.application.credentials.dig(Rails.env.to_sym, :a,:b,:c,:d) should return correct value.

Related