How do I prevent rails from redirecting to request referrer after create

You can define (in your controller) what the create action is after a successful save, and if you only want to do that for one format, and not the others, you can use the usual method for doing that in a controller, with:

if @foo.create(foo_params)   respond_to do |format|     if format.js       render status: :ok     else       redirect_to @foo     end   end else   render :new end

Using render status: :ok on success will not let anything else happen, no redirect, nothing changes on screen.

Walter

Cool Thanks I had solved this by removing respond_to and rails automatically returned 204 No content because there was no view Maybe that’s not a good hack though with no respond_to