Это не ответ, а просто примечание.
В Rails 5 есть redirect_back :
redirect_back fallback_location: { action: "show", id: 5 }
redirect_back fallback_location: post
redirect_back fallback_location: "http://www.rubyonrails.org"
redirect_back fallback_location: "/images/screenshot.jpg"
redirect_back fallback_location: articles_url
redirect_back fallback_location: proc { edit_post_url(@post) }
Источник:
def redirect_back(fallback_location,, **args)
if referer = request.headers["Referer"]
redirect_to referer, **args
else
redirect_to fallback_location, **args
end
end