On 6 Feb 2009, at 16:35, Steve Davie wrote:
> > I'm getting murdered by this thing! For the life of me, I can't > figure > it out. I've spent literally days on google. > > Here's what I would like to do (in rails 2.2.2): > > > <% if params[:cruise_info] %> > <%= collection_select :cabin_type, :cabin_type_id, > CabinType.find_by_status(1).collect {|ct| ct}, :id, :name, > {:selected => > params[:cruise_info][:cabin_type_id]}%> > <% end %> collection_select ignore the :selected option. Fred > > > The intent here is, on re-rendering the page (after a validation > failure), I don't want the end-user to be required to make the > selection > again. I have half a dozen collection_selects in this form that are > being returned from partials and are embeded with :fields_for, so > they're not automatically retaining their selections. > > Most of my search results are Bug reports for this, but they're more > than 2 years old. It's gotta be fixed by now right? I have to be > doing > something wrong? I just can't see it. I've tried using select, > options_from_collection_for_select, and have the same issue with all > of > them. I've tried different variations, like putting it in the options > => {} and in html_options => {}...and nothing. I've tried :selected, > :selected_value, I even tried using :include_blank => {...}, which i > knew wouldn't work, but thought it worth a try. I've tried to_s on > the > params (which btw are an integer), but i'm not even seeing the > "selected" option showing up in the html source. > > Sorry for being so long winded, I want to insure I include enough > information to get this solved. > > Any advice? > > Thanks in advance > -- > Posted via http://www.ruby-forum.com/. > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---