微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

ruby-on-rails-3 – Authlogic Rails 3.1

人们使用Rails 3.1版本的authlogic.

我的gemfile中有以下条目:

gem 'authlogic',:git => 'https://github.com/AndreasWurm/authlogic.git'

我的问题是在我的基础ApplicationController中的一段代码.

def require_no_user
  if current_user
    store_location
    flash[:notice] = "You must be logged out to access this page"
    redirect_to :controller => "home",:action => "index"
    return false
  end
end

def store_location
  session[:return_to] = request.request_uri
end

我得到的错误是:

session[:return_to] = request.request_uri

我得到一个错误说:

undefined method `request_uri' for #<Actiondispatch::Request:0x7dadd4d8>

请求_uri已从Actiondispatch中删除,如果是,是什么正确的替代方法

解决方法

最好的解决方案就是说 Vadim,使用Actiondispatch :: Request中的新方法

你只是替换:

def store_location
  session[:return_to] = request.request_uri
end

通过:

def store_location
  session[:return_to] = request.url
end

完成了!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐