I have a rails helper in my application_helper.rb file that looks like this:
def external_link(name)
url = external_links[name]
if url.blank?
Rails.logger.error "No URL defined for external link [#{name}]!"
return "[URL undefined]"
end
return url
end
The 'external_links' variable is a hash that should be sourced from an external file. The file can be something as simple as a ruby hash or a simple YML config.
Maybe I'm missing something - I thought I'd be able to define the hash in ruby syntax in an external file and 'require' it from environment.rb, but that doesn't expose the hash variable in the helper.
How can I externalise a ruby hash such that it will be "in scope" in an application helper method?