I want to be able to do the following actions with a form submit using respond_with:
- Submit then redirect to index
- Submit then stay in the form
- Submit and show the created record
the default action for respond_with is to redirect to the show action. How can I make the controller respond depending on the type of button clicked?
these “submits” will occur during create and update actions. For example, how would the create action in this code respond to whichever among the three submit buttons is clicked(Submit and Edit, Submit and Show, Submit and Show INdex)
def new
respond_with(@business=Business.new)
end
def create
@business = Business.new(params[:business])
flash[:notice] = t("flash.actions.create.notice", {:resource_name => "Business"}) if @business.save
respond_with(@business)
end
In your view, using the values
submit_and_edit,submit_and_showandsubmit_and_show_index, you would do this in your controller: