I'm using rails 5. I have this defined in my config/environments/development.rb file
config.hostname = “myapp.com"
and then I try and access this in a helper file by using
url = "https://#{config.hostname}/lti"
but this results in an error,
NameError: undefined local variable or method `config' for ScenariosHelper:Module
How do I access my config variable?
您可以通过Rails.configuration
访问Rails配置,因此请使用:
Rails.configuration.hostname
这应该工作:
url = "https://#{Rails.configuration.hostname}/lti"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.