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
>
> def set
> @practice_areas = PracticeArea.all
> @lpl_short_form_app = LPLShortFormApp.find(session[:lplsfa_id])
> @practice_areas.each do |practice_area|
> @practice_areas.lpl_short_form_apps << @lpl_short_form_app
> end
> end
>
> I know this is a long message, but I hope it gets a fair evaluation.
> It breaks down to my lack of understanding of many to many
> relationships in Ruby, my lack of understanding of the form_for in
> Rails, and my lack of understanding of both ruby/rails general syntax.
> I have the Ruby 1.9 Pickaxe book as well as the Agile Web Dev with
> Rail, 3rd ed. but having read through the beginning sections of both
> books hasn't cleared this up for me.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---