Sunday, December 28, 2008

Current option not getting selected in select box?

I have a, options) in one of my form. But after I submit and if there are any errors in the form it should show the errors and retain all the values in the form. But this attr1 was loosing its value. Instead of the previously selected option, it being reset to the first option. What was wrong?

att_accessible! The attribute wanted to be selected automatically must be in the attr_accessible list. Otherwise Rails won't attach "selected" property to that option.

No comments: