This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dumb-mistakes-and-gotchas category.
Last Updated: 2024-11-23
I had a Config
file and I wanted to add some config for you_tube
into a vast config file, so I added an entry:
class Config
...
def you_tube
{
api_key: Rails.application.credentials.dig(:you_tube, :data_api_key)
}
end
...
end
Later I got weird errors when another property that was supposed to be on the you_tube
config channel_id
, was missing. What had happened was that I had created a second method named you_tube
and it overrode the old one containing channel_id
. Here's that old one
def you_tube
{
channel_id: "xyz"
}
end
What I should have done is: a. had a linter check for repeated method names b. manually check for existing methods for adding one c. ESP. store all methods in alphabetical order in the config file (making the existing ones easy to see)
When the config items are alphabetical, this is fool proof.