Authlogic openid:获取未定义的方法 openid_identifier?功能测试错误
我将 Authlogic 与 Authlogic-openid 插件一起使用(我 gem 安装了 ruby- openid 和脚本/插件安装 git://github.com/rails/open_id_authentication.git) 并得到两个错误。
首先,在运行功能测试时,我得到一个未定义的方法 openid_标识符?当我的 new.html.erb 文件中的一行出现消息时 运行 UsersControllerTest。该行是:
<% 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 do |result|...
我觉得我错过了一些非常基本的东西,但我一直在盯着在 这个太久了,因为我找不到它是什么。我查了一下 Railscasts 第 160 集和第 170 集以及骨头 GitHub 项目上的代码 但什么也没发现。
感谢您的帮助,usr
I use Authlogic with the Authlogic-openid addon (I gem installed ruby-
openid and script/plugin install git://github.com/rails/open_id_authentication.git)
and get two errors.
First when running functional test, I get an undefined method
openid_identifier? message on a line in my new.html.erb file when
running the UsersControllerTest. The line is:
<% if @user.openid_identifier? %>
When running script/console I can access this method without any
problem.
Second when testing the openid functionality and registering a new
user to my application using openid and using my blogspot account for
that I get the following in my log file:
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'
The code in the users_controller is straight forward:
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
The line giving the error being @user.save do |result|...
I feel I'm missing something pretty basic but I have been staring at
this for too long because I can't find what it is. I checked with the
code on Railscasts episodes 160 and 170 and the bones GitHub project
but found nothing.
Thanks for your help, usr
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
问题是同时使用了 authlogic_oauth 和 authlogic_openid 插件。这意味着用户的 save 方法将由 openid 代码而不是 oauth 代码处理。
也许 authlogic_rpx 库可以成功地结合这两种方法,我仍然需要测试这一点。
The problem is the fact that the authlogic_oauth and authlogic_openid plugins were used at the same time. This means that the save method on user will be handled by the openid code instaed of the oauth code.
Maybe the authlogic_rpx library can combine the two methods succesfully, I need to test this still.
您确定@user已设置吗?在我看来,问题在于 @user 为零。
Are you sure that @user is set? Seems to me that the problem is that @user is nil.