I have a controller called "products_controllers.rb" that have this method:
def create
...
...
respond_to do |format|
if @product.save
???????
else
format.html { render :action => "new" }
format.xml { render :xml => @product.errors, :status => :unprocessable_entity }
end
end
Whenever the product is save I want to redirect it to an specific view called "suppliers", that belongs to the product views, how can I do that? Thanks in advance!
If you're using restful routes and there is a relationship where product has many suppliers, you could use:
format.html { redirect_to product_suppliers_url(@product) }
with something like this in your routes.rb:
map.resource :products do |product|
product.resource :suppliers
end
or you could also just use this:
format.html { redirect_to :action => 'suppliers', :id => @product.id }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With