Rails select list reverts to top?

Posted by Danny McClelland on Stack Overflow See other posts from Stack Overflow or by Danny McClelland
Published on 2010-05-18T11:17:12Z Indexed on 2010/05/18 11:20 UTC
Read the original article Hit count: 194

Filed under:
|
|

Hi Everyone,

I have number of select lists in my rails application like this:

<li>Company<span><%= f.select :company_id, Company.all.collect {|m| [m.companyname, m.id]} %></span></li>

They all work well, except - sometimes if you go to the edit view, the select list reverts to the top item, not the item that was chosen when creating. So if you go to an edit view and then click update without actually making any changes, the lists default to the top item - even though you didn't touch them.

Is there a way around this?

Thanks,

Danny

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about select