0

I use following f.select query:

= f.select(:category_id, @categories, :html_options => {:class => 'select_box'}, {:disabled => lambda{ |category| category.id == 18 }})

And this line return me a syntax error... why? All braces should be closed...

2 Answers 2

2
= f.select(:category_id, @categories, :html_options => {:class => 'select_box'}, {:disabled => lambda{ |category| category.id == 18 }})

should be

= f.select(:category_id, @categories, :html_options => {:class => 'select_box', :disabled => lambda{ |category| category.id == 18 }})

You had the disabled option in its own hash

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

Comments

1

According to the api, the method is defined as

f.select(method, choices, options = {}, html_options = {})

where :disabled is an option and :class would be an html_option, so the call should probably be written as

f.select(:category_id, @categories, {:disabled => lambda{ |category| category.id == 18 }}, { :class => 'select_box' }).

The last set of brackets shouldn't be necessary, though.

Comments

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.