2010-06-15 26 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

相關問題