Ruby f.select: Syntax for assigning a css class?

ECOLOGY

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 (maybe a stupid question) what is the correct 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 the last line (broken for display).

This syntax (and many similar to it) is either ignored or cannot cause errors (either).

+4
source share
1 answer

It seems to me that when I read the documentation your code should be:

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

Since you only want to specify html_options , just go to the empty Hash {} for options .

+12
source

Source: https://habr.com/ru/post/1434966/


All Articles