2011-10-22 1 views
5

내 RSpec에 테스트 나에게RSpec에 사용자 테스트는 "정의되지 않은 지역 변수 또는 메소드`confirmed_at '"

NameError: 
    undefined local variable or method `confirmed_at' for #<User:0xca6ff98> 

내 사용자 사양을주고 있습니다

class DeviseCreateUsers < ActiveRecord::Migration 
    def self.up 
    create_table(:users) do |t| 
     t.database_authenticatable :null => false 
     t.recoverable 
     t.rememberable 
     t.trackable 

     # t.encryptable 
     # t.confirmable 
     # t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both 
     # t.token_authenticatable 


     t.timestamps 
    end 

    add_index :users, :email,    :unique => true 
    add_index :users, :reset_password_token, :unique => true 
    # add_index :users, :confirmation_token, :unique => true 
    # add_index :users, :unlock_token,   :unique => true 
    # add_index :users, :authentication_token, :unique => true 
    end 

    def self.down 
    drop_table :users 
    end 
end 
:

confirmed_at 나는 1.4.8 내 사용자 마이그레이션이었다 고안해야

내 사용자 테이블은 다음과 같습니다 당신이 어딘가에 길을 따라 고안은 "위한 확 인"구성을 놓친처럼

mysql> describe users; 
+------------------------+--------------+------+-----+---------+----------------+ 
| Field     | Type   | Null | Key | Default | Extra   | 
+------------------------+--------------+------+-----+---------+----------------+ 
| id      | int(11)  | NO | PRI | NULL | auto_increment | 
| email     | varchar(255) | NO | UNI |   |    | 
| encrypted_password  | varchar(128) | NO |  |   |    | 
| reset_password_token | varchar(255) | YES | UNI | NULL |    | 
| reset_password_sent_at | datetime  | YES |  | NULL |    | 
| remember_created_at | datetime  | YES |  | NULL |    | 
| sign_in_count   | int(11)  | YES |  | 0  |    | 
| current_sign_in_at  | datetime  | YES |  | NULL |    | 
| last_sign_in_at  | datetime  | YES |  | NULL |    | 
| current_sign_in_ip  | varchar(255) | YES |  | NULL |    | 
| last_sign_in_ip  | varchar(255) | YES |  | NULL |    | 
| created_at    | datetime  | YES |  | NULL |    | 
| updated_at    | datetime  | YES |  | NULL |    | 
| last_name    | varchar(255) | YES |  | NULL |    | 
| first_name    | varchar(255) | YES |  | NULL |    | 
+------------------------+--------------+------+-----+---------+----------------+ 
+1

Devise는 사용자에게'confirmed_at'을 요구합니까? 나는 결코 그것을 사용하지 않고 단지 야생의 추측 일뿐입니다. –

+0

감사합니다 mu! 그래,하지만 그렇게 보인다 괴괴 망측하게 발전기의 그것을 포함하지 않습니다 전에 가서 수동으로 추가하면 다른 사람이 본 적이 있는지보고 싶어. –

+0

아마도 누락 된 마이그레이션입니까? http://groups.google.com/group/plataformatec-devise/browse_thread/thread/f7d79b0cdada6992 –

답변

7

보인다. 당신은 세 가지 누락 된 열을 직접 추가하거나 this thread 하단 Reza.Hashemi의 메시지가 표시 (이런 식으로 뭔가를 시도 할 수 있습니다 : 마지막으로,

def self.up 
    change_table(:users) do |t| 
    t.confirmable 
    end 
end 

과 :

$ rails g migration addconfirmable 

다음이로 마이그레이션을 편집 보통 :

$ rake db:migrate 

나는 위의 과정이 세 개의 열을 추가해야한다고 생각 :

,369
  • confirmation_sent_at :datetime
  • 당신을 위해

  • confirmation_token :string
    • confirmed_at :datetime
    • . 아니면 손으로 할 수 있습니다.

    +0

    위대한 뮤, thx, 당신은 최고! –

    +0

    이 답변을 Devise v3에 업데이트 할 수 있습니까? : D – Jeff

    +0

    @Jeff : 죄송합니다. 현재 Devise를 사용하고 있지 않으므로 v3에 필요한 항목을 모르겠습니다. –

    0

    몽고 이드의 경우 사용자 모델을 살펴보십시오. 필요한 필드가 주석 처리 될 수 있습니다. 나를 위해 그들은 다음과 같았습니다 :

    ## Confirmable 
    field :confirmation_token, :type => String 
    field :confirmed_at,   :type => Time 
    field :confirmation_sent_at, :type => Time 
    field :unconfirmed_email, :type => String # Only if using reconfirmable