How to define id or class for options_for_select in rails?

how can we determine the id for this rail select statement, I tried to do it the way

<%= f.select :state, options_for_select(Contact::STATES), :id=>"state_job" %> 

but it does not show the id when I check it in the browser. Please help me

 <%= f.select :state, options_for_select(Contact::STATES) %> 
+4
source share
1 answer

select tag helper looks for options , then html_options , you just need to make sure your identifier is in the right place ( html_options ) by passing something to the options parameter:

 <%= f.select :state, options_for_select(Contact::STATES), {}, {:id=>"state_job"} %> 
+9
source

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


All Articles