ruby-on-rails-3 – Authlogic Rails 3.1
发布时间:2020-12-16 20:03:49 所属栏目:百科 来源:网络整理
导读:人们使用Rails 3.1版本的authlogic. 我的gemfile中有以下条目: gem 'authlogic',:git = 'https://github.com/AndreasWurm/authlogic.git' 我的问题是在我的基础ApplicationController中的一段代码. def require_no_user if current_user store_location fla
人们使用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 完成了! (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |