Hi guys,
anybody encountered such a problem that <% form_remote_tag ... %> doesn't send the data present in the form on submit?
Let me explain:
I have Products and the products have Properties.
# routes.rb map.resources :products do |product| product.resources :properties end
I have a product edit form, which lists all the properties currently assigned to the product row by row, simple.
# _properties.rb <% @product.properties.each do |property| %> <tr> <td> <% form_remote_tag( :url => property_path( @product, property ), :method => :put ) do %> <input id="property_name" name="property[name]" value="<%= property.name %>" /> <input id="property_value" name="property[value]" value="< %= property.value %>" /> <%= submit_tag "Save" %> <% end %> </td> </tr> <% end %>
The property controller takes care of updating:
# properties_controller.rb def update return false unless request.xhr? @property = ProductProperty.find( params[:id] )
# debug logger.info "PARAMS: #{params.inspect}"
@property.update_attributes( params[:property] ) @product = Product.find( params[:product_id] ) end
All fine and dandy, there are 3 properties listed, I changed the values in the form and click save next to it. Log says:
# development.log ProductProperty Columns (0.007000) SHOW FIELDS FROM product_properties ProductProperty Load (0.002000) SELECT * FROM product_properties WHERE (product_properties.`id` = 18) PARAMS: {"action"=>"update", "product_id"=>"1", "id"=>"18", "controller"=>"properties"}
NoMethodError (You have a nil object when you didn't expect it!) ...
Of course nil, because params[:property] is nil and i'm trying to udpate_properties( ) on it. Log says, no additional parameters passed along with the request, but which were present in the form_remote_tag declaration.
Some additional info: same situation, plain <% form_tag ... %> works like a charm. Seems like a bug in <% form_remote_tag ... %>.
Am I missing something? Tried everything at my disposal, still no luck. I'm on edge rails, latest revision.
Thanks and my best regards, András