Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Authlogic Rails 3.1

Which version of authlogic are people using with Rails 3.1.

I have the following entry in my gemfile:

gem 'authlogic', :git => 'https://github.com/AndreasWurm/authlogic.git'

The problem I have is with a piece of code in my base 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

The error I am getting is with the line:

session[:return_to] = request.request_uri

I am getting an error saying:

undefined method `request_uri' for #<ActionDispatch::Request:0x7dadd4d8>

Has Request_uri been removed from ActionDispatch and if so, what is the correct alternative?

like image 382
dagda1 Avatar asked Jul 24 '11 07:07

dagda1


2 Answers

The best solution is as said Vadim, using the new methods in ActionDispatch::Request :

You just replace :

def store_location
  session[:return_to] = request.request_uri
end

by :

def store_location
  session[:return_to] = request.url
end

and it's done !

like image 57
Kzu Avatar answered Dec 06 '22 16:12

Kzu


fullpath will give you url(but without protocol, port, domain) with params and request.url will give you everything that fullpath skips

like image 25
Vadim Chumel Avatar answered Dec 06 '22 15:12

Vadim Chumel