Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/53.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails ruby中的条件语句_Ruby On Rails_Syntax - Fatal编程技术网

Ruby on rails ruby中的条件语句

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

我正试图在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
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个参数