Form_remote_tag is not passing form params

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:

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 } %>

<%= 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 %>

<%= 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

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

Could this be the problem?

http://codefluency.com/articles/2006/06/02/rails-views-using-the-with-option
/

www.jefdean.com
[email protected]
917 414 7801

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs