ruby on rails redirect_to(:back)无效

Rya*_*yan 3 redirect ruby-on-rails

在Agile Web Development的一些代码中,有一个方法是使用redirect_to(:back)重定向回到最后查看的页面,但是当我这样做时,它只返回它所在的页面.

什么是获得理想结果的最佳方式?难道我做错了什么?我的代码:

def update
@user = current_user
if @user.update_attributes(params[:user])
  flash[:notice] = "Successfully updated profile."
  redirect_to(:back)
else
  render :action => 'edit'
end
end
Run Code Online (Sandbox Code Playgroud)

And*_*ell 8

我认为它的行为符合预期:

:back - 返回发出请求的页面.适用于从多个位置触发的表单.