Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to define id or class for options_for_select in rails?

how can we define id for this rails select statement , i have tried doing in this way like

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

but it is not showing any id when i inspect it in the browser. Please help me out

<%= f.select :state, options_for_select(Contact::STATES) %>
like image 619
sidhu Avatar asked Aug 28 '13 10:08

sidhu


1 Answers

The select tag helper looks for options, then html_options, you just need to make sure your id 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"} %>
like image 104
Matt Avatar answered Oct 07 '22 12:10

Matt