Aside from the fact that the 'edit' method in the following
product_admin_controller is using request.post? instead of creating a
separate 'update' method, are there any issues with the code that is
immediately apparent and I am overlooking?
def edit
@product = Product.find(params[:id])
if request.post?
if @product.update_attributes(params[:product])
flash[:notice] = "Success."
redirect_to :action => 'list'
unless @product.styles_valid?
flash[:notice] = "Error."
else
flash[:notice] = "Success."
end
else
flash[:notice] = "Error."
flash[:error_field] = :product
end
end
end
I have tried to insert a raise after request.post? but my application
doesn't make contact with this.
Of course, I've ensured my form method is set to "post".
I have tried to insert a raise after request.post? but my application
doesn't make contact with this.
Of course, I've ensured my form method is set to "post".
Hi,
Why you want to post your form on same(i.e edit) method..??
As in rails already has CRUD good feature. So y need to custom your form
submit flow.?
Anyway.. I would give following solution for you case
1- check that routes.rb file
if u have
map.resources :product_admin
then replace those routes using
map.with_options :controller => :product_admin do |pp|
pp.edit 'product_admin/edit/:id', :action => :edit
..
..ur all methods routes should be here
..
end
2 - check you edit.html.erb file
add :url => {:action => :edit} in you form tag
One main thing in your controller prefer params[:product_admin] or
whatever ur form array instead of request.post?
Hi,
Why you want to post your form on same (i.e edit) method?
As in rails already has CRUD good feature. So y need to custom your form
submit flow?
I asked myself the very same question; it was not me that built the
site. I can assure you that if it were me, it would follow the CRUD
framework.
Anyway... I would give following solution for you case
1- check that routes.rb file
if u have
map.resources :product_admin
then replace those routes using
map.with_options :controller => :product_admin do |pp|
pp.edit 'product_admin/edit/:id', :action => :edit
..
..ur all methods routes should be here
..
end
2 - check you edit.html.erb file
add :url => {:action => :edit} in you form tag
One main thing in your controller prefer params[:product_admin] or
whatever ur form array instead of request.post?