Skip to content


February 1, 2011

devise is gem package. it is used to authenticate the site

At first create a rails project

$ rails new product -d mysql

$ cd product/

and the edit the config/database.yml file to put the mysql password

$ rake db:create

then install devise via gem it is a one time installation no need to install another projects

$ sudo gem install devise –version=1.1.rc0

edit gem file to add the  following

gem ‘devise’, ‘1.1.rc0’

and then

$ bundle install

$ rails generate devise_install

add the line in config/environment/development.rb

config.action_mailer.default_url_options = { :host => ‘localhost:3000’ }

add the line in config/routes.rb

root :to => “products#index”

create a user model

$ rails generate devise User

in user.rb

devise :database_authenticatable, :registerable,

:recoverable, :rememberable, :trackable, :validatable

(remove the :confirmable in the above code)

In …devise_create_users.rb to put the comment lines

# t.confirmable

# add_index :users, :confirmation_token,

migrate the database

$ rake db:migrate

$ rake routes

$ rails server

open the browser type the url  http://localhost:3000/users/sign_in

it display the signin page click the signup to enter the authentication details

finally sign_out the session like http://localhost:3000/users/sign_out

No comments yet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: