2010-01-26 40 views
0

我使用Authlogic-openid插件(我安裝了ruby- openid和腳本/插件安裝git://github.com/rails/open_id_authentication.git) 並得到兩個錯誤。Authlogic openid:獲取未定義的方法openid_identifier?功能測試中的錯誤

首先運行功能測試的時候,我得到一個未定義的方法 openid_identifier?在運行UsersControllerTest的 時,我的new.html.erb文件中的一行消息。該生產線是:

<% if @user.openid_identifier? %> 

當運行腳本/控制檯,我可以沒有任何 問題訪問此方法。

第二測試時,OpenID的功能和使用OpenID新 用戶註冊到我的應用程序和使用我的BlogSpot帳戶 ,我得到我的日誌文件如下:

Generated checkid_setup request to http://www.blogger.com/openid-server.g 
with assocication ... 
Redirected to http://www.blogger.com/openid-server.g?openid.assoc_handle=... 
NoMethodError (You have a nil object when you didn't expect it! 
The error occurred while evaluating nil.call): 
    app/controllers/users_controller.rb:44:in `create' 
    /usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service' 
    /usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run' 
    /usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread' 
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start' 
    /usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread' 
    /usr/lib/ruby/1.8/webrick/server.rb:95:in `start' 
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `each' 
    /usr/lib/ruby/1.8/webrick/server.rb:92:in `start' 
    /usr/lib/ruby/1.8/webrick/server.rb:23:in `start' 
    /usr/lib/ruby/1.8/webrick/server.rb:82:in `start' 

在users_controller的代碼是直截了當:

def create 
    respond_to do |format| 
     @user.save do |result| 
       if result 
       flash[:notice] = t('Thanks for signing up!') 
       format.html { redirect_to :action => 'index' } 
       format.xml { render :xml => @user, :status => :created, :location => @user } 
       else 
       format.html { render :action => "new" } 
       format.xml { render :xml => @user.errors, :status => :unprocessable_entity } 
       end 
     end 
    end 
    end 

線給誤差爲@ user.save做|結果| ...

我覺得我錯過了一些非常基本的東西,但我一直盯着 這太久了,因爲我找不到它是什麼。我檢查了Railscasts 160和170上的 代碼和骨頭GitHub項目 ,但沒有發現任何東西。

感謝您的幫助,usr

回答

0

您確定已設置@user嗎?在我看來,問題在於@user是零。

+0

是的,這是我使用聲明的授權和行 filter_resource_access 是在users_controller.rb的頂部。即使我添加 @user = User.new(PARAMS [:用戶]) 之前保存,我得到了同樣的錯誤。 我認爲這可能是我使用博客作爲openid提供程序的事實,但是如果我使用openid.org,我仍然會得到相同的錯誤。 –

1

問題在於,authlogic_oauth和authlogic_openid插件是同時使用的。這意味着用戶的保存方法將由oauth代碼中的openid代碼處理。

也許authlogic_rpx庫可以成功地使用這兩種方法,我需要還進行測試。

相關問題