I''ve searched and searched and searched again, and I cannot find any help with this problem. There''s an identical problem on this forum, but it was never resolved. I''ll try to re-open the subject with a bit more information. Problem: The form_remote_tag() method in my "list" view is not passing the params[] hash of the values stored within my form. I''m not sure whether this is because I have multiple (one per database row) forms to update the fields for multiple objects or not. Rendered HTML Code from my view: <form action="/contacts/ajax_list_update/1" method="post" name="form1" onsubmit="new Ajax.Updater(''contact_1_div'', ''/contacts/ajax_list_update/1'', {asynchronous:true, evalScripts:true, parameters:Form.serialize(this)}); return false;"> <input type="text" name="test" value="2222" /> <input id="contact1_first_name" name="contact1[first_name]" size="10" type="text" value="Bob" /> <input id="contact1_last_name" name="contact1[last_name]" size="15" type="text" value="Jones" /> </form> My view template (RHTML) looks like this (the "contact" object is a single iteration through the @contacts array of objects): <%= form_remote_tag :update => "contact_" + contact.id.to_s + "_div", :url => { :action => "ajax_list_update", :id => contact.id }, :html => { :name => "form" + contact.id.to_s } %> <input type="text" name="test" value="2222" /> <%= text_field "contact" + contact.id.to_s, "first_name", :value => contact.first_name, :size => 10 %> <%= text_field "contact" + contact.id.to_s, "last_name", :value => contact.last_name, :size => 15 %> <input type="submit" name="submit" value="Update" /> <%= end_form_tag %> My controller''s ajax_list_update method: def ajax_list_update @contact = Contact.find(params[:id]) logger.debug params.inspect @contact.update_attributes(params["contact_" + @contact.id.to_s]) render :partial => "list_element" end When I click the submit button, the Ajax.Updater call correctly fires (prototype is definitely being called in my view), and the ajax_list_update method is being run. Inside the method, however, the params[] hash has only the following values: {"action"=>"ajax_list_update", "id"=>"2", "controller"=>"contacts"}. Where are my other form values?! Where is params[:contact1][:first_name]? Where is params[:2222]? Adam -- Posted via http://www.ruby-forum.com/.
I''m trying to setup some mildly complex associations for a project we''re working on and can''t seem to find much documentation on n-way has_many :through associations. I have the following models: Person, PhysicalAddress, EmailAddress, PhoneNumber. Each person can have multiple PhysicalAddresses, EmailAddresses, and PhoneNumbers, and multiple people can share the same PhysicalAddress, EmailAddress, or PhoneNumber. I need to track the types of associations (i.e. home, work, cell, etc) for each, so habtm definitely won''t cut it. Do I need to setup separate join tables for each association (people_physical_addresses, people_phone_numbers, etc), or should I have a ''contacts'' (for lack of a better name at the moment) table with several columns for person_id, physical_address_id, phone_number_id, email_address_id, & contact_type. Or should I do something else entirely? Thanks!
Hello Adam, Can you try to NOT set the :id param - the rendered html(js) ''/ contacts/ajax_list_update/1'' looks a little fishy. There may be a problem with specifying that param plus the parameter serialization. That''s just a guess given what you''ve posted. Jodi On 23-Jun-06, at 7:38 PM, Adam B. Traver wrote:> I''ve searched and searched and searched again, and I cannot find any > help with this problem. There''s an identical problem on this forum, > but > it was never resolved. I''ll try to re-open the subject with a bit more > information. > > Problem: The form_remote_tag() method in my "list" view is not passing > the params[] hash of the values stored within my form. I''m not sure > whether this is because I have multiple (one per database row) > forms to > update the fields for multiple objects or not. > > Rendered HTML Code from my view: > > <form action="/contacts/ajax_list_update/1" method="post" name="form1" > onsubmit="new Ajax.Updater(''contact_1_div'', > ''/contacts/ajax_list_update/1'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this)}); return false;"> > <input type="text" name="test" value="2222" /> > <input id="contact1_first_name" name="contact1[first_name]" size="10" > type="text" value="Bob" /> > <input id="contact1_last_name" name="contact1[last_name]" size="15" > type="text" value="Jones" /> > </form> > > My view template (RHTML) looks like this (the "contact" object is a > single iteration through the @contacts array of objects): > > <%= form_remote_tag :update => "contact_" + contact.id.to_s + "_div", > :url => { :action => "ajax_list_update", :id => contact.id }, :html > => { > :name => "form" + contact.id.to_s } %> > <input type="text" name="test" value="2222" /> > <%= text_field "contact" + contact.id.to_s, "first_name", :value => > contact.first_name, :size => 10 %> > <%= text_field "contact" + contact.id.to_s, "last_name", :value => > contact.last_name, :size => 15 %> > <input type="submit" name="submit" value="Update" /> > <%= end_form_tag %> > > My controller''s ajax_list_update method: > > def ajax_list_update > @contact = Contact.find(params[:id]) > > logger.debug params.inspect > > @contact.update_attributes(params["contact_" + @contact.id.to_s]) > > render :partial => "list_element" > end > > When I click the submit button, the Ajax.Updater call correctly fires > (prototype is definitely being called in my view), and the > ajax_list_update method is being run. Inside the method, however, the > params[] hash has only the following values: > {"action"=>"ajax_list_update", "id"=>"2", "controller"=>"contacts"}. > > Where are my other form values?! Where is > params[:contact1][:first_name]? Where is params[:2222]? > > Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails
Could this be the problem? http://codefluency.com/articles/2006/06/02/rails-views-using-the-with-option / www.jefdean.com jeff@jefdean.com 917 414 7801 -----Original Message----- From: Jodi Showers [mailto:jodi@nNovation.ca] Sent: Friday, June 23, 2006 10:14 PM To: rails@lists.rubyonrails.org Subject: Re: [Rails] form_remote_tag is not passing form params Hello Adam, Can you try to NOT set the :id param - the rendered html(js) ''/ contacts/ajax_list_update/1'' looks a little fishy. There may be a problem with specifying that param plus the parameter serialization. That''s just a guess given what you''ve posted. Jodi On 23-Jun-06, at 7:38 PM, Adam B. Traver wrote:> I''ve searched and searched and searched again, and I cannot find any > help with this problem. There''s an identical problem on this forum, > but > it was never resolved. I''ll try to re-open the subject with a bit more > information. > > Problem: The form_remote_tag() method in my "list" view is not passing > the params[] hash of the values stored within my form. I''m not sure > whether this is because I have multiple (one per database row) > forms to > update the fields for multiple objects or not. > > Rendered HTML Code from my view: > > <form action="/contacts/ajax_list_update/1" method="post" name="form1" > onsubmit="new Ajax.Updater(''contact_1_div'', > ''/contacts/ajax_list_update/1'', {asynchronous:true, evalScripts:true, > parameters:Form.serialize(this)}); return false;"> > <input type="text" name="test" value="2222" /> > <input id="contact1_first_name" name="contact1[first_name]"size="10"> type="text" value="Bob" /> > <input id="contact1_last_name" name="contact1[last_name]" size="15" > type="text" value="Jones" /> > </form> > > My view template (RHTML) looks like this (the "contact" object is a > single iteration through the @contacts array of objects): > > <%= form_remote_tag :update => "contact_" + contact.id.to_s + "_div", > :url => { :action => "ajax_list_update", :id => contact.id }, :html > => { > :name => "form" + contact.id.to_s } %> > <input type="text" name="test" value="2222" /> > <%= text_field "contact" + contact.id.to_s, "first_name", :value => > contact.first_name, :size => 10 %> > <%= text_field "contact" + contact.id.to_s, "last_name", :value => > contact.last_name, :size => 15 %> > <input type="submit" name="submit" value="Update" /> > <%= end_form_tag %> > > My controller''s ajax_list_update method: > > def ajax_list_update > @contact = Contact.find(params[:id]) > > logger.debug params.inspect > > @contact.update_attributes(params["contact_" + @contact.id.to_s]) > > render :partial => "list_element" > end > > When I click the submit button, the Ajax.Updater call correctly fires > (prototype is definitely being called in my view), and the > ajax_list_update method is being run. Inside the method, however, the > params[] hash has only the following values: > {"action"=>"ajax_list_update", "id"=>"2", "controller"=>"contacts"}. > > Where are my other form values?! Where is > params[:contact1][:first_name]? Where is params[:2222]? > > Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails