added token to users model and generate token method to users controller

This commit is contained in:
relotnek
2014-03-11 20:28:15 -04:00
parent c559bd5602
commit e7c30151d4
3 changed files with 13 additions and 1 deletions
+6
View File
@@ -81,5 +81,11 @@ private
end
end
end
def generate_token(column)
begin
self[column] = SecureRandom.urlsafe_base64
end while User.exists?(column => self[column])
end
end
@@ -0,0 +1,5 @@
class AddAuthTokenToUsers < ActiveRecord::Migration
def change
add_column :users, :auth_token, :string
end
end
+2 -1
View File
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20131113200708) do
ActiveRecord::Schema.define(:version => 20140312002642) do
create_table "benefits", :force => true do |t|
t.datetime "created_at", :null => false
@@ -83,6 +83,7 @@ ActiveRecord::Schema.define(:version => 20131113200708) do
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "auth_token"
end
create_table "work_infos", :force => true do |t|