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
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.