Reinstalled devise to user model and migration

This commit is contained in:
Will Bradley 2012-09-02 04:12:26 -07:00
parent 72f5a1202a
commit 99f24fe144
5 changed files with 87 additions and 4 deletions

View File

@ -1,4 +1,12 @@
class User < ActiveRecord::Base class User < ActiveRecord::Base
# Include default devise modules. Others available are:
# :token_authenticatable, :confirmable,
# :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
# Setup accessible (or protected) attributes for your model
attr_accessible :email, :password, :password_confirmation, :remember_me
require 'open-uri' require 'open-uri'
attr_accessible :card_id, :card_number, :card_permissions, :name attr_accessible :card_id, :card_number, :card_permissions, :name

View File

@ -82,7 +82,7 @@ Devise.setup do |config|
config.stretches = Rails.env.test? ? 1 : 10 config.stretches = Rails.env.test? ? 1 : 10
# Setup a pepper to generate the encrypted password. # Setup a pepper to generate the encrypted password.
# config.pepper = "eced55b3a4acf0aa9187e0e705474f780fc8480f8bfb7009b672b0ecaef204b3a4669cdbab82df033d4234f39d4db3c64d4857d2823e8aa9fa4c55c1a9c6e4c9" # config.pepper = "a2406b0a0ef9399b1367e2a43c435e4e946b5e1ee75644af793405515ce3361c2fe47bcec51a1095f480cf08ab6d7073b12034c92e6e63779245f968a88888f9"
# ==> Configuration for :confirmable # ==> Configuration for :confirmable
# A period that the user is allowed to access the website even without # A period that the user is allowed to access the website even without

View File

@ -1,5 +1,7 @@
Dooraccess::Application.routes.draw do Dooraccess::Application.routes.draw do
devise_for :users
match 'users/upload_all' => 'users#upload_all', :as => :upload_all match 'users/upload_all' => 'users#upload_all', :as => :upload_all
resources :users resources :users
match 'users/:id/upload' => 'users#upload', :as => :upload match 'users/:id/upload' => 'users#upload', :as => :upload

View File

@ -0,0 +1,60 @@
class AddDeviseToUsers < ActiveRecord::Migration
def self.up
change_table(:users) do |t|
## Database authenticatable
t.string :email, :null => false, :default => ""
t.string :encrypted_password, :null => false, :default => ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
t.integer :sign_in_count, :default => 0
t.datetime :current_sign_in_at
t.datetime :last_sign_in_at
t.string :current_sign_in_ip
t.string :last_sign_in_ip
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
## Token authenticatable
# t.string :authentication_token
# Uncomment below if timestamps were not included in your original model.
# t.timestamps
end
@users = User.all
@users.each do |u|
u.email = (100000*rand()).to_s+"@example.com"
u.save
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
# By default, we don't want to make any assumption about how to roll back a migration when your
# model already existed. Please edit below which fields you would like to remove in this migration.
raise ActiveRecord::IrreversibleMigration
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120825041626) do ActiveRecord::Schema.define(:version => 20120902105919) do
create_table "door_logs", :force => true do |t| create_table "door_logs", :force => true do |t|
t.string "key" t.string "key"
@ -24,8 +24,21 @@ ActiveRecord::Schema.define(:version => 20120825041626) do
t.integer "card_id" t.integer "card_id"
t.string "card_number" t.string "card_number"
t.integer "card_permissions" t.integer "card_permissions"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", :default => 0
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.string "current_sign_in_ip"
t.string "last_sign_in_ip"
end end
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
end end