人们使用哪种版本的authlogic与Rails 3.1.
我的gemfile中有以下条目:
gem 'authlogic', :git => 'https://github.com/AndreasWurm/authlogic.git'
Run Code Online (Sandbox Code Playgroud)
我遇到的问题是我的基础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
Run Code Online (Sandbox Code Playgroud)
我得到的错误是与行:
session[:return_to] = request.request_uri
Run Code Online (Sandbox Code Playgroud)
我收到一个错误说:
undefined method `request_uri' for #<ActionDispatch::Request:0x7dadd4d8>
Run Code Online (Sandbox Code Playgroud)
Request_uri是否已从ActionDispatch中删除,如果是,那么正确的选择是什么?
小智 30
最好的解决方案就像Vadim所说,使用ActionDispatch :: Request中的新方法:
你只需要替换:
def store_location
session[:return_to] = request.request_uri
end
Run Code Online (Sandbox Code Playgroud)
通过:
def store_location
session[:return_to] = request.url
end
Run Code Online (Sandbox Code Playgroud)
它已经完成了!