Created
January 27, 2012 07:56
-
-
Save Amitesh/1687703 to your computer and use it in GitHub Desktop.
Add Devise
This file contains hidden or 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
- Add in Gem file | |
gem devise | |
- Install devise | |
$ rails generate devise:install | |
- Generate user model and routes | |
$ rails generate devise user | |
- Add extra fields | |
$ rails g migration addFieldsToUser name:string company:string address:string | |
- Generate views | |
$ rails generate devise:views users | |
- Add other modules | |
devise :database_authenticatable, :registerable, :confirmable, | |
:recoverable, :rememberable, :trackable, :validatable | |
Model file should be like this | |
class User < ActiveRecord::Base | |
# Include default devise modules. Others available are: | |
# :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable | |
devise :database_authenticatable, :registerable, :confirmable, | |
:recoverable, :rememberable, :trackable, :validatable | |
# Setup accessible (or protected) attributes for your model | |
attr_accessible :name, :email, :password, :password_confirmation, :remember_me | |
validates_presence_of :name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment