hi guys, Ruby 1.8.7 Rails 2.3.5 I have a nested form in which a select drop down works fine for creating the model, but on edit form it does not show the current value. It gets set to the default option. The domain is like this: Listing <has_one> Address <belongs_to> Neighbourhood The drop down used to work for address edit form, before nesting the model. address.rb -> http://gist.github.com/310879 partial _address_form.html.erb -> http://gist.github.com/310880 The method @neighbourhood_for_metro in following snippet is a helper which works perfectly fine. <p> <%= address_form.label :neighbourhood %><br /> <%= collection_select(:address,:neighbourood,@neighbourhood_for_metro,:id,:name) %> </p> I spent enough time on this issue to know its some silly thing that I am missing. I would really appreciate if any one could help me solve this issue. regards, aakash -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Try changing the method to :neighbourhood_id -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Aakash Dharmadhikari
2010-Feb-22 09:58 UTC
Re: Re: collection_select not working for nested forms
I have tried that, no change in behaviour. On Mon, Feb 22, 2010 at 2:43 PM, Sharagoz -- <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Try changing the method to :neighbourhood_id > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Any difference if you change :address to @address? If that doesnt work, I guess you''ll have to do :selected => @address.neighbourhood_id -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Aakash Dharmadhikari
2010-Feb-23 04:11 UTC
Re: Re: Re: collection_select not working for nested forms
using address_form.collection_select(:neighbourhood_id,@neighbourhood_for_metro,:id,:name) worked rather than collection_select(@object,@method,...) it seems use of form specific methods avoids a lot of trouble, when shifting forms from individual to nested. On Mon, Feb 22, 2010 at 3:48 PM, Sharagoz -- <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Any difference if you change :address to @address? > > If that doesnt work, I guess you''ll have to do :selected => > @address.neighbourhood_id > -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hello, Spotted a little typo in http://gist.github.com/310880 on line 15: < %collection_select(:address,:neighbourood,@neighbourhood_for_metro,:id,:name) %> That :neighbourood missing h. Maybe theres your problem? On Feb 22, 9:02 am, Aakash Dharmadhikari <aaka...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi guys, > > Ruby 1.8.7 > Rails 2.3.5 > > I have a nested form in which a select drop down works fine for creating > the model, but on edit form it does not show the current value. > It gets set to the default option. > > The domain is like this: > Listing <has_one> Address <belongs_to> Neighbourhood > > The drop down used to work for address edit form, before nesting the > model. > > address.rb ->http://gist.github.com/310879 > partial _address_form.html.erb ->http://gist.github.com/310880 > > The method @neighbourhood_for_metro in following snippet is a helper which > works perfectly fine. > > <p> > <%= address_form.label :neighbourhood %><br /> > <%= collection_select(:address,:neighbourood,@neighbourhood_for_metro,:id,:name) > %> > </p> > > I spent enough time on this issue to know its some silly thing that > I am missing. > > I would really appreciate if any one could help me solve this issue. > > regards, > aakash-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.