I have my third-party credentials set in the config/application.rb like a key, UUID, and other values.
config.username = "username"
config.uuid = "uuid"
config.yyy = "yyy"
For fetching them, I have to write multiple lines to fetch the data which is
Rails.application.config.key
Rails.application.config.UUID
Rails.application.config.yyy
Instead of using the above, I have defined an array with a set of elements loop through it, and get the config value. But I am not able to get the config value, since fetching through a variable is not allowing. Let me know if any alternative
arr = ["key", "uuid", "vv"]
arr.each do |v|
# Fetching the config value from application config
Rails.application.config.v
# Or
Rails.application.config."#{v}"
end
Getting an error saying - undefined method `v' for #Rails::Application::Configuration:0x0000000152e4f360 (or) SyntaxError ((irb):1919: syntax error, unexpected tSTRING_BEG) ...ass; Rails.application.config."#{v}"