Ruby on rails 3 成功登录后,用户单击浏览器的“后退”按钮;“登录”;页面不应出现

Ruby on rails 3 成功登录后,用户单击浏览器的“后退”按钮;“登录”;页面不应出现,ruby-on-rails-3,authentication,login,Ruby On Rails 3,Authentication,Login,我有一个登录页面,用户在其中输入电子邮件和密码,然后用户被重定向到主页,但当我按下后退按钮时,它会将我带回登录页面。如何防止这种情况在rails 3中发生?将其添加到LoginController(用于登录的控制器)中 这将清除浏览器历史记录 before_filter :set_cache_buster def set_cache_buster response.headers["Cache-Control"] = "no-cache, no-store, max-age=0

我有一个登录页面,用户在其中输入电子邮件和密码,然后用户被重定向到主页,但当我按下后退按钮时,它会将我带回登录页面。如何防止这种情况在rails 3中发生?

将其添加到LoginController(用于登录的控制器)中

这将清除浏览器历史记录

 before_filter :set_cache_buster

  def set_cache_buster
    response.headers["Cache-Control"] = "no-cache, no-store, max-age=0, must-revalidate"
    response.headers["Pragma"] = "no-cache"
    response.headers["Expires"] = "Fri, 01 Jan 1990 00:00:00 GMT"
  end