Commit 35bafcda

mo khan <mo@mokhan.ca>
2013-06-18 03:12:08
add devise columns to users
1 parent 0bb5eea
app/models/user.rb
@@ -1,7 +1,7 @@
 class User < ActiveRecord::Base
   validates :name,  :presence => true
   validates :website, :format => URI::regexp(%w(http https)), :allow_blank => true
-  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
+  devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :token_authenticatable
   attr_accessible :name, :email, :website, :twitter, :facebook, :city, :latitude, :longitude, :password, :password_confirmation, :current_password, :remember_me, :interest_ids
   has_many :creations, :dependent => :destroy
   has_many :favorites, :dependent => :destroy
db/migrate/20130618030337_add_devise_columns_to_users.rb
@@ -0,0 +1,27 @@
+class AddDeviseColumnsToUsers < ActiveRecord::Migration
+  def change
+    ## Encryptable
+    add_column :users, :password_salt, :string
+
+    ## Confirmable
+    add_column :users, :confirmation_token, :string
+    add_column :users, :confirmed_at, :datetime
+    add_column :users, :confirmation_sent_at, :datetime
+    add_column :users, :unconfirmed_email, :string
+
+    ## Lockable
+    add_column :users, :failed_attempts, :integer, :default => 0
+    add_column :users, :unlock_token, :string
+    add_column :users, :locked_at, :datetime
+
+    # Token authenticatable
+    add_column :users, :authentication_token, :string
+
+    ## Invitable
+    add_column :users, :invitation_token, :string
+
+    add_index :users, :confirmation_token,   :unique => true
+    add_index :users, :unlock_token,         :unique => true
+    add_index :users, :authentication_token, :unique => true
+  end
+end
db/schema.rb
@@ -11,7 +11,7 @@
 #
 # It's strongly recommended to check this file into your version control system.
 
-ActiveRecord::Schema.define(:version => 20130617041448) do
+ActiveRecord::Schema.define(:version => 20130618030337) do
 
   create_table "active_admin_comments", :force => true do |t|
     t.integer  "resource_id",   :null => false
@@ -201,11 +201,24 @@ ActiveRecord::Schema.define(:version => 20130617041448) do
     t.string   "city"
     t.float    "latitude"
     t.float    "longitude"
+    t.string   "password_salt"
+    t.string   "confirmation_token"
+    t.datetime "confirmed_at"
+    t.datetime "confirmation_sent_at"
+    t.string   "unconfirmed_email"
+    t.integer  "failed_attempts",                       :default => 0
+    t.string   "unlock_token"
+    t.datetime "locked_at"
+    t.string   "authentication_token"
+    t.string   "invitation_token"
   end
 
+  add_index "users", ["authentication_token"], :name => "index_users_on_authentication_token", :unique => true
+  add_index "users", ["confirmation_token"], :name => "index_users_on_confirmation_token", :unique => true
   add_index "users", ["created_at"], :name => "index_users_on_created_at"
   add_index "users", ["email"], :name => "index_users_on_email", :unique => true
   add_index "users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
+  add_index "users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true
 
   create_table "users_interests", :id => false, :force => true do |t|
     t.integer "user_id"