4

ENVIRONMENT

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin10.8.0]; Rails 3.2.6; OSX 10.6.8

QUESTION

Having tried many permutations of the following syntax, I have to ask (the probably stupid question), what is the proper syntax for assigning .css classes to Ruby f.select objects?

<%= f.select :fieldname, 
options_for_select( [[ t('selector_instruction_string'), ""]] + countries, 
resource.fieldname), 
html_options { :class => 'Select_100pct' } %>

See last line (broken for display).

This syntax (and many like it) are either ignored, or fail to raise errors (either).

1

1 Answer 1

16

To me it seems that, when I read the documentation, your code should be:

<%= f.select :fieldname, options_for_select(...), {}, { :class => 'Select_100pct' } %>

Because you only want to specify html_options, just pass in an empty Hash {} for options.

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

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.