Given the following controller.
class Posts_controller < ApplicationController
def create
@post = Post.new(:params[:post])
flash[:notice] = 'Post successfully saved' if @post.save
respond_with(@post, :location => my_custom_url)
end
end
In the event that a post is not saved, i.e. because it fails one or more validations, the controller goes to my_custom_url rather than rendering the 'new' view which it would do when no location would be given.
Is there any way to stop this behaviour from being overriden?
It turns out that the location is not changed after all, but that the code fails during url generation https://github.com/rails/rails/issues/2798.