I’m having some truble redirecting my users to the previous page.
Here is an example of an update method in the movies controller.
def update
@movie = Movie.find(params[:id])
if @movie.update_attributes(params[:movie])
flash[:notice] = "The given movie is now updated."
end
respond_with(@movie, location: :back)
end
I’m getting this error.
undefined method 'hash_for_back_url' for #<Module:0x00000103eeaaa8> on the respond_with line.
I’m using Rails 3.1 rc1 with Ruby 1.9.
It works when doing something like this.
respond_with(@movie, location: request.referer)
Anyone knows why the :back argument won’t work?
The only solution that worked for me was the use of
request.referer.Solution #1
Solution #2