0

I am getting the following error when rake db:migrate is run:

undefined method `confirmable' for #<ActiveRecord::ConnectionAdapters::Table:0x6d448e8>
c:/java/RubyProjects/myproject/db/migrate/20111202225103_make_user_confirmable.rb:4:in `block in change'
c:/java/RubyProjects/myproject/db/migrate/20111202225103_make_user_confirmable.rb:3:in `change'
c:in `migrate'
Tasks: TOP => db:migrate

user.rb:

class User < ActiveRecord::Base

  devise :database_authenticatable, :registerable, 
         :recoverable, :rememberable, :trackable, :validatable

  # Setup accessible (or protected) attributes for your model
  attr_accessible :email, :password, :password_confirmation, :remember_me

  # Include default devise modules. Others available are:
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
  devise :database_authenticatable, :registerable,
         :recoverable, :rememberable, :trackable, :validatable, :confirmable

  ...

end

20111202225103_make_user_confirmable.rb:

class MakeUserConfirmable < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.confirmable
    end

    add_index :users, :confirmation_token,   :unique => true
  end
end

Not sure what else is to be done..

Please help.

Amit Kumar Gupta
  • 17,184
  • 7
  • 46
  • 64
  • What are you trying to accomplish? Doing `devise :confirmable` in your `User` model adds the Devise "confirmable" *module* to your User *model*, it doesn't add a *method* to your *table*. – Amit Kumar Gupta Apr 14 '13 at 06:58
  • See this answer [http://stackoverflow.com/questions/4783392/how-do-i-enable-confirmable-in-devise][1] [1]: http://stackoverflow.com/questions/4783392/how-do-i-enable-confirmable-in-devise – Rabbott Apr 14 '13 at 07:38

1 Answers1

3

edited:
How To: Add :confirmable to Users

P.S.
There's no such type as confirmable in rails migrations, so the migration fails.
But if you still want to add confirmable column to user table:

class MakeUserConfirmable < ActiveRecord::Migration
  def change
    change_table(:users) do |t|
      t.boolean :confirmable, :default => false
    end
  end
end
ted
  • 5,219
  • 7
  • 36
  • 63