2010-06-15 20 views
0

我想获得authlogic和openid发生在我的应用程序。迄今为止它已经严重不愉快。我试图关注该主题的Railscasts,但没有一个宝石或插件似乎工作。未定义的方法`openid_identifier'为#<AccountSession:没有凭据提供>

A在阅读了关于previous error后,最终安装了this open-id plugin(在该页面的底部提到)。现在我得到的错误:

ActionView::TemplateError (undefined method `openid_identifier' for #<AccountSession: no credentials provided>) on line #13 of app/views/account_sessions/new.html.haml: 

我不能确定这是否有改进。

的观点:

%h3 
    Login: 
- form_for(@account_session) do |f| 
    = f.error_messages 
    %p 
    =t 'account.login' 
    =f.text_field :login 
    %p 
    =t 'account.password' 
    =f.password_field :password 
    %p 
    =t 'account.openid_identifier' 
    =f.text_field :openid_identifier 

控制器:安装

class AccountSessionsController < ApplicationController 

     def new 
     @account_session = AccountSession.new 
     end 

     def create 
     @account_session = AccountSession.new(params[:account_session]) 

     @account_session.save do |result| 
     if result 
      flash[:notice] = I18n.t 'session.login_success' 
      redirect_to root_url 
     else 
      render :action => "new" 
     end 
     end 
     end 

     def destroy 
     @Account_session = AccountSession.find 
     @Account_session.destroy 
     flash[:notice] = I18n.t('session.logout_message') 
     redirect_to root_url 
     end 
    end  

宝石:

authlogic (2.1.5, 2.1.4, 2.1.3) 
authlogic-oid (1.0.4) 
ruby-openid (2.1.8, 2.1.7) 

这将是听到它只是我做一些愚蠢的好消息。它已经很晚了,我一直在考虑这个时间太长,所以很有可能。

谢谢!

回答

0

你看过插件的文档(http://github.com/binarylogic/authlogic_openid)吗?这听起来像你忘了创建/运行以下迁移:

class AddUsersOpenidField < ActiveRecord::Migration 
    def self.up 
     add_column :users, :openid_identifier, :string 
     add_index :users, :openid_identifier 

     change_column :users, :login, :string, :default => nil, :null => true 
     change_column :users, :crypted_password, :string, :default => nil, :null => true 
     change_column :users, :password_salt, :string, :default => nil, :null => true 
    end 

    def self.down 
     remove_column :users, :openid_identifier 

     [:login, :crypted_password, :password_salt].each do |field| 
     User.all(:conditions => "#{field} is NULL").each { |user| user.update_attribute(field, "") if user.send(field).nil? } 
     change_column :users, field, :string, :default => "", :null => false 
     end 
    end 
    end 
+0

我结束了粘贴所有到另一个迁移。它虽然...... – mikewilliamson 2010-06-16 04:58:34

+0

不知道,但它看起来你正在@account_session上调用openid_identifier,但如果你看看迁移它openid_identifier是一种方法:用户。 – sosborn 2010-06-17 23:05:53

相关问题