I have a model Products that belongs_to a model Store (which has_many products).
When I create a new product for a store, I'm using this url:
/products/new?store_id=4
When a product creation fails validation, I am being redirected to:
/products
Here is the respond_to for this "create" action:
respond_to do |format|
if @product.save
format.html { redirect_to(@product.store, :notice => 'Product was successfully created.') }
format.xml { render :xml => @product, :status => :created, :location => @product }
else
format.html { render :action => "new" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
Ideally, I'd like to redirect the user on a failed create back to the exact url as before, namely:
/products/new?store_id=4
Thanks,
Harris