在发布新模型的帖子期间,我正在通过 Authlogic 检查身份验证。有一个before_filter
关于创建请求。它在呼唤require_user
。成功创建用户会话后,将redirect_back_or_default(default)
调用该方法。问题是,请求需要发布到存储的 uri。我试图存储该方法并将其输入到redirect_to
但它不起作用。有任何想法吗?
# called before successful authentication with before_filter
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def store_location
session[:return_to] = request.request_uri
session[:return_to_method] = request.request_method
end
# called after successful authentication
def redirect_back_or_default(default)
redirect_to((session[:return_to] ? session[:return_to] : default), :method => session[:return_to_method])
session[:return_to] = nil
session[:return_to_method] = nil
end