During a post for a new model, I am checking for authentication via Authlogic. There is a before_filter
on the create request. It is calling require_user
. After the user session has been successfully created, the redirect_back_or_default(default)
method is called. The problem is, The request needs to be posted to the stored uri. I have tried to store the method and input it into the redirect_to
however it isn't working. Any ideas?
# 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