I am a Ruby on Rails developer with over two years of experience, most of which is working remotely. I am a typical Punekar and in my free time I play badminton, workout, go trekking and I like to interact with people. Feel free to slide into my DMs and say Hi! 😄
1 minute read
Since Rails 5.2 was released, we can make use of the Credentials API to manage our secrets.
Check out our previous blog on
Rails credentials
to learn more about the working of the API.
Example
Consider config/credentials.yml.enc contains the following configuration:
Before
Earlier we could only access the top-level key using the dot (.) syntax (i.e., Using a method call).
The nested keys had to be accessed using the [] syntax.
After
As we can see in the last example, trying to access a nested key using the dot syntax raises a NoMethodError.
Rails 7
adds
the ability to access nested secrets using the dot syntax (i.e., Using a method call).
Now it is possible to access the nested key access_key_id as follows: