# Model update/create not saved to params\[\]

**URL:** <https://www.ruby-forum.com/t/model-update-create-not-saved-to-params/158188>\
**Category:** Rails\
**Created:** [January 20, 2009, 10:15am UTC](https://www.ruby-forum.com/t/model-update-create-not-saved-to-params/158188 "2009-01-20T10:15:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gte351s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@gte351s](https://www.ruby-forum.com/u/gte351s)\
**Post date:** [January 20, 2009, 10:15am UTC](https://www.ruby-forum.com/t/model-update-create-not-saved-to-params/158188/1 "2009-01-20T10:15:04Z")

</div>

I’m trying to build a form to create or update a model using remote  
call. When I submit the form, I see that the changes aren’t applied. I  
started the server with --debugger and noticed the params hash doesn’t  
receive the updates. My code for update form is this:

# /app/views/vendors/\_vendor.html.erb

# This is in the partial b/c there’s also an option to render a

# read only view as a table row with vendor\_nnn as its id
\<% if edit\_mode -%\> \<% form\_for @vendor, :vendor, { :action =\> 'update', :id =\> @vendor } do |f| -%\> \<%= f.text\_field :name %\> \<%= f.text\_field :location %\> \<%= link\_to\_remote 'save', :url =\> { :action =\> 'update', :id =\> @vendor } %\> \<% end -%\> \<% end -%\>
# vendors\_controller.rb

def update  
@vendor = Vendor.find(params[:id])  
if @vendor.update\_attributes(params[:vendor])  
flash[:notice] = “Vendor **#{@vendor.name}** was successfully  
updated.”  
respond\_to do |format|  
format.html { redirect\_to vendors\_path }  
format.js  
end  
end  
end

# update.js.rjs – this is just to

id = params[:id]

# this puts

page.replace “vendor\_#{id}”,  
:partial =\> ‘vendor’,  
:object =\> Vendor.find(id),  
:locals =\> { :edit\_mode =\> false }

page.replace\_html ‘flasher’, params[:vendor] unless  
params[:vendor].blank?  
page.remove “active\_vendor”

When submitting the form it just renders the previous data, without the  
changes.

---

<div class="post-metadata">

**Author:** ![gte351s](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/5f9b8f/32.png) [@gte351s](https://www.ruby-forum.com/u/gte351s)\
**Post date:** [January 21, 2009, 4:45am UTC](https://www.ruby-forum.com/t/model-update-create-not-saved-to-params/158188/2 "2009-01-21T04:45:51Z")

</div>

You will want to use remote\_form\_for instead of form\_for.

A bit of unasked-for advice:

Write your tests or specs and run them all the time. Make sure  
everything works without the ajax. Tail your logs and watch the  
actions invoked and parameters passed.

Hope this helps.
