1

I am trying to write Helper method in rails but its throwing error for following line

#if button_source.kind_of?(Array) then list = button_source else list = button_source.sort

The complete code

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

Please help me to resolve this issue, thanks.

0

1 Answer 1

1

You're missing an end at the end of the if statement.

Sign up to request clarification or add additional context in comments.

2 Comments

yes right, i have noticed that, but still getting another error while using <%= buttons(:person, country_array) %> in view
You pass 2 args but your method requires 3

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.