Frederick Cheung wrote: > On Apr 30, 10:24�pm, "Ahad L. Amdani" <[email protected]> wrote: > >> >> So, my questions are as follows: >> 1. How do I have the submit button go to the "Set" action defined in >> the practices_controller? > > by default this form would submit to the update (if the record > existed) or create (if it didn't) url for that practice - which > doesn;t sound quite right - the model you are editing > is LPLShortFormApp as I understand it (since the list of areas is a > fixed list). if what you are doing feels like an update/edit/create i > would stick with the default set of actions rather than create a set > action > >> 2. How do I collect/scrape each of the individual percentages from the >> form so that I can validate them against a total of 100%? > > you're going to have to plough through the params hash. right now it > will be bust since all of your form inputs have the same name (and so > will overwrite each other). The form helpers guide (on > guides.rubyonrails.org) has information on dealing with that sort of > thing. > >> 3. How do I take that collection and generate a new record in the >> practices table such that it joins the LPLSFA with the Practice Area? >> Each LPLSFA will have all 30 practice areas, so 30 practices records, >> most of which will probably be at a 0 percentage. I'm imagining >> something like this: > > you're starting to get into the complex forms arena (ie a form that > does not edit/update a single row in the database). one way of going > it would be to have a method on LPLShortFormApp that took as an > argument the info from the params and created the rows in the join > table. > > Fred
Thanks for the assistance. I've been looking at the guides, and I found this in 7.3 of the forms guide: <% form_for @person do |person_form| %> <%= person_form.text_field :name %> <% for address in @person.addresses %> <% person_form.fields_for address, :index => address do |address_form|%> <%= address_form.text_field :city %> <% end %> <% end %> <% end %> I believe I can do something similar with @lpl_short_form_app.practices :) I'll try it out and report my results, for people who may be searching for similar results. -- 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 [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---

