[英]conditional statement in ruby
我正在尝试在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 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
请帮助我解决此问题,谢谢。
您在if语句的末尾缺少结尾。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.