2011-07-24 11 views
12

Rails 3.1で使用している人のauthlogicのバージョン。Authlogic Rails 3.1

は、私は私のgemfileに次のエントリを持っている:

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

私が持っている問題は、私の基本ApplicationControllerに内のコードの一部です。

session[:return_to] = request.request_uri 

私はというエラーを取得しています:

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 

私は取得していますエラーがラインである

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

はREQUEST_URIがActionDispatchから削除されているそうであれば、何がある 正しい代替?

答えて

7

fullpathあなたを与えるだろうURL(しかし、プロトコル、ポート、ドメインなし)のparams とrequest.urlであなたにfullpathスキップ

30

が最善の解決策はActionDispatchで新しいメソッドを使用して、Vadimを言ったようにされたすべてのものを提供します::リクエスト:

あなただけの置き換え:

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

によって:

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

となっています!

+0

これは素晴らしいです!うまく仕事します。 – Nizzy