7
Allow access to nested secrets by method calls by ghiculescu · Pull Request #421...
source link: https://github.com/rails/rails/pull/42106
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
In a new Rails app, the generated credentials file contains an example of some nested secrets.
Currently you can't access them nicely the way you would top level secrets:
2.7.3 :001 > Rails.application.credentials.aws
=> {:access_key_id=>123, :secret_access_key=>345}
2.7.3 :002 > Rails.application.credentials.aws.access_key_id
Traceback (most recent call last):
1: from (irb):2
NoMethodError (undefined method `access_key_id' for {:access_key_id=>123, :secret_access_key=>345}:Hash)
It would make secrets easier to use if you could, so this PR adds support for that. Rails.application.credentials.aws.access_key_id
will now return 123
in the above example.
The old method of hash access remains unchanged.
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK