【发布时间】:2016-01-23 00:03:52
【问题描述】:
我正在尝试创建一个通用方法,该方法采用我的 Rails 变量(对应于 YAML 键)并获取 YAML 数据。
settings.yml
features:
first_feature: true
second_feature: false
导轨功能
def my_function(feature)
Settings.features.#{feature} # where #{feature} passes my param
end
使用示例:
my_function(first_feature)
# => true
不确定这是否可能——还没有运气。
【问题讨论】:
-
@Jordan
Settings引用 settings.yml 并且链式方法在 settings.yml 中找到features。
标签: ruby-on-rails yaml