I have a User model created already. I am wondering how should I configure devise with my existing User model. That being said, do I need to setup any additional routes or make atttributes accessible in my user method.
So far user model is
class User < ActiveRecord::Base
attr_accessible :email, :pic, :name, :username
has_many :topics
end
My migration for CreateUsers
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.string :name
t.string :email
t.string :username
t.string :pic
t.timestamps
end
end
end
Now what I plan to do is run
rails g migration AddDeviseColumnsToUser
And add this to my migration file
class AddDeviseColumnsToUser < ActiveRecord::Migration
def change
change_table :users do |t|
t.string :encrypted_password, :null => false, :default => '', :limit => 128
t.confirmable
t.recoverable
t.rememberable
t.trackable
t.token_authenticatable
t.timestamps
end
end
end
Now I am wondering how should I setup my routes or do I have to ? And what attributes should be made accessible in my User model?
Update: I have already installed Devise and configured it with
rails generate devise:install
You can simply run:
to add devise to the User model.
Just add
devise_for :user
in your routesAdd
attr_accessible :password, :password_confirmation
and for more info take a look at a typical devise model
https://github.com/johndel/Rails-Simple-CMS/blob/master/app/models/admin.rb
(Pretty simple)