Ruby on rails ruby中的条件语句
我正试图在rails中编写Helper方法,但它在下面的行中抛出了错误Ruby on rails ruby中的条件语句,ruby-on-rails,syntax,Ruby On Rails,Syntax,我正试图在rails中编写Helper方法,但它在下面的行中抛出了错误 #if button_source.kind_of?(Array) then list = button_source else list = button_source.sort 完整代码 def buttons(model_name, target_property, button_source) html = '' list = '' if button_source.kind_of?(Array) then lis
#if button_source.kind_of?(Array) then list = button_source else list = button_source.sort
完整代码
def buttons(model_name, target_property, button_source)
html = ''
list = ''
if button_source.kind_of?(Array) then list = button_source else list = button_source.sort end
list = button_source.sort
list.each do|x|
html << radio_button(model_name, target_property, x[1])
html << h(x[0])
html << '<br />'
end
return html
end
def按钮(型号名称、目标属性、按钮源)
html=“”
列表=“”
如果button\u source.kind\u of?(数组)则list=button\u source else list=button\u source.sort end
列表=按钮\u source.sort
列出每个do | x|
html您在if语句的结尾缺少一个结尾。您在if语句的结尾缺少一个结尾。是的,我注意到了,但是在视图中使用
时仍然出现另一个错误您传递了2个参数,但您的方法需要3个是的,我注意到,但在视图中使用
时仍会出现另一个错误。您传递了2个参数,但您的方法需要3个参数