ncancelliere
2008-Jun-08 14:57 UTC
Unable to get selected option with options_from_collection_for_select
I''m in Rails 2.1, Ruby 1.8.6 -- http://pastie.org/211063 <%= params[:doctor_id] %> <%options_from_collection_for_select(Doctor.active, :id, :name, :selected => params[:doctor_id]) %> <%options_from_collection_for_select(Doctor.active, :id, :name, :selected_value => params[:doctor_id]) %> Returns: 53 <option value="49">Michael Summer</option> <option value="52">Susan Miller</option> <option value="53">Kenny Storm</option> <option value="55">Tank Bordem</option> <option value="49">Michael Summer</option> <option value="52">Susan Miller</option> <option value="53">Kenny Storm</option> <option value="55">Tank Bordem</option> So params[:doctor_id] is clearly = to Kenny Storm (value 53) but it is not adding selected to the tag. Any ideas? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
ramon.tayag-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jun-08 15:00 UTC
Re: Unable to get selected option with options_from_collection_for_select
Make sure you''ve placed it in the right hash of arguments. Maybe it''s something like <%= options_from_collection_for_select(Doctor.active, :id, :name, {}, {:selected => params[:doctor_id]}) %> On 6/8/08, ncancelliere <ncancelliere-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I''m in Rails 2.1, Ruby 1.8.6 -- > > http://pastie.org/211063 > > <%= params[:doctor_id] %> > <%> options_from_collection_for_select(Doctor.active, :id, :name, :selected > => params[:doctor_id]) %> > > <%> options_from_collection_for_select(Doctor.active, :id, :name, > :selected_value > => params[:doctor_id]) %> > > Returns: > > 53 > <option value="49">Michael Summer</option> > <option value="52">Susan Miller</option> > <option value="53">Kenny Storm</option> > <option value="55">Tank Bordem</option> > > <option value="49">Michael Summer</option> > <option value="52">Susan Miller</option> > <option value="53">Kenny Storm</option> > <option value="55">Tank Bordem</option> > > > So params[:doctor_id] is clearly = to Kenny Storm (value 53) but it is > not adding selected to the tag. > > Any ideas? > > >-- Ramon Tayag --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---