0
我有config/application.rb
文件中的配置變量如下,如何追加字符串配置變量
config.user1= 'http://localhost:3001/user1'
config.user2= 'http://localhost:3002/user2'
config.user3= 'http://localhost:3003/user1'
config.user4= 'http://localhost:3004/user2'
我希望得到的配置變量動態如下,
a='.user1'
def config_d(a)
@b='Rails.configuration'[email protected]
puts @b #out put should be value of configuration variables 'http://localhost:3001/user1'
end
我必須通過a
動態地以config_d(user1)
爲例
config(user1)
應該返回http://localhost:3001/user1
config(user2)
應該返回http://localhost:3002/user2
建議我任何技術來獲得配置從字符串或哈希或任何其它數據結構的值。
在此先感謝, 蘇雷什