我使用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
是的,这是我使用声明的授权和行 filter_resource_access 是在users_controller.rb的顶部。即使我添加 @user = User.new(PARAMS [:用户]) 之前保存,我得到了同样的错误。 我认为这可能是我使用博客作为openid提供程序的事实,但是如果我使用openid.org,我仍然会得到相同的错误。 –