Created
December 10, 2011 01:30
-
-
Save nahurst/1454190 to your computer and use it in GitHub Desktop.
Add TokenAuthenticatable to an existing user model for devise
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remember to add "devise :token_authenticatable" to user.rb | |
# and uncomment "config.token_authentication_key = :auth_token" from devise.rb | |
class AddTokenAuthenticatableToUsers < ActiveRecord::Migration | |
def self.up | |
change_table(:users) do |t| | |
t.token_authenticatable | |
end | |
User.reset_column_information | |
User.all.each do |user| | |
user.ensure_authentication_token | |
user.save | |
end | |
end | |
def self.down | |
remove_column :users, :authentication_token | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment