sidhu
sidhu

Reputation: 53

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) %>

Upvotes: 5

Views: 2583

Answers (1)

Matt
Matt

Reputation: 14038

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"} %>

Upvotes: 11

Related Questions