人们在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>是否已从ActionDispatch中删除了Request_uri ?如果已删除,正确的替代方案是什么?
发布于 2011-08-23 21:45:04
最好的解决方案是如前所述的Vadim,使用ActionDispatch::Request中的新方法:
您只需替换:
def store_location
session[:return_to] = request.request_uri
end出自:
def store_location
session[:return_to] = request.url
end一切都完成了!
发布于 2011-08-12 03:35:32
fullpath将提供带参数的url(但不包括协议、端口、域),而request.url将提供fullpath跳过的所有内容
https://stackoverflow.com/questions/6805547
复制相似问题