我正在处理一些文件,我需要在控制器和控制器内部的方法中传递一些yaml文件属性,但是我不能,它总是返回“ nil类的未定义方法”
def method
yml_import
variable = class.other_method('action',@yaml_file['index']['property'])
end
private
def yml_import
@yaml_file = YAML.load_file(File.join("path to file.yml"))
end
我希望变量获取yaml文件属性内的字符串,但事实并非如此。返回我“ nil类的未定义方法”。
def method
yml_import if conditional
var1 = class.new('args') #this is ok this part was already functioning
var2 = var1.other_method('action',@yaml_file['index']['property']) # this line is the cursed
end