hi guys, I have a fairly simple application for a party. An "invite" object has many "guest" objects. When I open up localhost:3000/invites/:id/guests/, I expect to see the details of the "invite" along with all the guest objects associated with the given invite. I would like to have a form whereby there''s a checkbox on the left of each guest entry which represents if the guest has decided to attend the party (or not). Nevertheless, I kept getting this error, " undefined method `guest_path'' for #<ActionView::Base:0x0000001138fe88>" when i open the url above. I am not sure what I am doing wrong. Anyway, this is how my "~/ projects/party/app/views/guests/index.rhtml" looks like. Yes, I am aware this is not following CRUD closely but it''s a very simple app hence I have stripped a lot of things down. ---------- extract start ------------------------------- <h1>Listing guests</h1> <% @guests.each do |guest| %> <% form_for(guest) do |f| %> <%= f.error_messages %> <p> <%= f.label :name %><br /> <%= f.text_field :name %> </p> <p> <%= f.label :contact_number %><br /> <%= f.text_field :contact_number %> </p> <p> <%= f.label :status %><br /> <%= f.check_box :status %> </p> <p> <%= f.label :email %><br /> <%= f.text_field :email %> </p> <p> <%= f.submit ''Update'' %> </p> <% end %> <% end %> ---------- extract end ------------------------------- Any ideas on how to create the multielement form, guys? thanks -- 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.
I''m not a professional Rails developper but I believe I went through the same kind of issue. So take a look at this: http://railscasts.com/episodes/75-complex-forms-part-1 and possibly part-2 and 3 as well. Christophe Le 6 avr. 2010 à 08:01, ct9a a écrit :> hi guys, > > I have a fairly simple application for a party. > > An "invite" object has many "guest" objects. > > > When I open up localhost:3000/invites/:id/guests/, I expect to see > the details of the "invite" along with all the guest objects > associated with the given invite. > > I would like to have a form whereby there''s a checkbox on the left of > each guest entry which represents if the > guest has decided to attend the party (or not). > > Nevertheless, I kept getting this error, " undefined method > `guest_path'' for #<ActionView::Base:0x0000001138fe88>" when i open the > url above. > > I am not sure what I am doing wrong. Anyway, this is how my "~/ > projects/party/app/views/guests/index.rhtml" > looks like. Yes, I am aware this is not following CRUD closely but > it''s a very simple app hence I have stripped a lot of things down. > > ---------- extract start ------------------------------- > > > > <h1>Listing guests</h1> > > <% @guests.each do |guest| %> > <% form_for(guest) do |f| %> > <%= f.error_messages %> > > <p> > <%= f.label :name %><br /> > <%= f.text_field :name %> > </p> > <p> > <%= f.label :contact_number %><br /> > <%= f.text_field :contact_number %> > </p> > <p> > <%= f.label :status %><br /> > <%= f.check_box :status %> > </p> > <p> > <%= f.label :email %><br /> > <%= f.text_field :email %> > </p> > <p> > <%= f.submit ''Update'' %> > </p> > <% end %> > <% end %> > > ---------- extract end ------------------------------- > > > Any ideas on how to create the multielement form, guys? > > thanks > > -- > 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. >-- 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.
It seems that you created the guest and invite routes nested, right? So, you have to write your form like this: <% form_for([@invite, guest]) do |f| %> This form above will use the url: /invites/:invite_id/guests/:id/edit Some reference: http://adamblog.heroku.com/past/2007/12/20/nested_resources_in_rails_2/ Cheers! Nícolas Iensen On Apr 6, 3:01 am, ct9a <anexi...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi guys, > > I have a fairly simple application for a party. > > An "invite" object has many "guest" objects. > > When I open up localhost:3000/invites/:id/guests/, I expect to see > the details of the "invite" along with all the guest objects > associated with the given invite. > > I would like to have a form whereby there''s a checkbox on the left of > each guest entry which represents if the > guest has decided to attend the party (or not). > > Nevertheless, I kept getting this error, " undefined method > `guest_path'' for #<ActionView::Base:0x0000001138fe88>" when i open the > url above. > > I am not sure what I am doing wrong. Anyway, this is how my "~/ > projects/party/app/views/guests/index.rhtml" > looks like. Yes, I am aware this is not following CRUD closely but > it''s a very simple app hence I have stripped a lot of things down. > > ---------- extract start ------------------------------- > > <h1>Listing guests</h1> > > <% @guests.each do |guest| %> > <% form_for(guest) do |f| %> > <%= f.error_messages %> > > <p> > <%= f.label :name %><br /> > <%= f.text_field :name %> > </p> > <p> > <%= f.label :contact_number %><br /> > <%= f.text_field :contact_number %> > </p> > <p> > <%= f.label :status %><br /> > <%= f.check_box :status %> > </p> > <p> > <%= f.label :email %><br /> > <%= f.text_field :email %> > </p> > <p> > <%= f.submit ''Update'' %> > </p> > <% end %> > <% end %> > > ---------- extract end ------------------------------- > > Any ideas on how to create the multielement form, guys? > > thanks-- 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.