Howdy, I''m new to rails and I''m learning form Agile Web Dev with Rails. It seems all of the examples that use form_for use it in situations where the action first creates a new object before doing a request.post... If I''m in a situation where I''m managing Roles, Rights, and assignments of rights to roles, I may want to have one little form with a text field and a "Create Role" button, another little form with a text field and a "Create Right" button, etc... in those situations is there a use for a form_for at all? An action can''t presuppose that I''m going to be using either or, so should I just create separate actions to invoke from the separate forms (ex ''create_new_role'', ''create_new_right'', etc) using form_tag and then redirect :back? (Sorry, on my previous post I accidentally said "form_tag" in the topic and it doesn''t let me edit... so I reposted.) -- 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-/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 -~----------~----~----~----~------~----~------~--~---
Sheldon Hearn
2007-Feb-13 07:58 UTC
Re: form_for only for single-form pages? (ignore previous)
On Feb 13, 8:47 am, Dave Smith <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> If I''m in a situation where I''m managing Roles, Rights, and assignments > of rights to roles, I may want to have one little form with a text field > and a "Create Role" button, another little form with a text field and a > "Create Right" button, etc... in those situations is there a use for a > form_for at all? An action can''t presuppose that I''m going to be using > either or, so should I just create separate actions to invoke from the > separate forms (ex ''create_new_role'', ''create_new_right'', etc) using > form_tag and then redirect :back?You definitely want the one form to POST to /roles and the other to POST to /rights, but I''m not sure how that precludes you from using form_for. Perhaps you haven''t noticed that a form_for uses a block that has a do and an end? So you just create the first form with form_for do ... end and then create the next form with form_for do ... end. You can have as many forms as you like on a single page. Ciao, Sheldon. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---