Monday, 26 August 2013

Preselect value dynamically in a select

Preselect value dynamically in a select References I have the following select for an associated object instance: <%= f.select :shop_id, Shop.all.map {|shop| [shop.name, shop.id]} %> I want to preselect one of the option values dynamically, i.e. different from time to time. I\'ve tried what is given in other so-answers (e.g. http://stackoverflow.com/a/5216513/1417223) but nothing is happening. How do I preselect an option value, off of an ID?

No comments:

Post a Comment