Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Devise - taking care of your users

Devise - taking care of your users

A quick intro to the Devise, the signup module for Ruby on Rails

Andreas Bjärlestam

February 22, 2011
Tweet

More Decks by Andreas Bjärlestam

Other Decks in Technology

Transcript

  1. This could require quite some coding Signup page Login page

    Account confirmation mails Password reset mails Password reset page Checks and redirects
  2. DEVISE •  User authentication •  User signup •  Account confirmaiton

    •  Password recovery •  Remembering via cookie •  Session expiration •  Account locking http://github.com/plataformatec/devise
  3. Create a rails project $>rails new devise_test $>cd devise_test $>gem

    install devise $>echo "gem 'devise'" >> Gemfile $>rails generate devise:install $>cat config/routes.rb | sed s/'# root :to'/'root :to'/ >> config/routes.rb
  4. configuration Configured routes config/routes.rb devise_for :users Configuration file and localization

    config/initializers/devise.rb config/initializers/locales/devise.en.yml
  5. User model class User < ActiveRecord::Base # Include default devise

    modules. Others available are: # :token_authenticatable, :confirmable, :lockable and :timeoutable devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable # Setup accessible (or protected) attributes for your model attr_accessible :email, :password, :password_confirmation, :remember_me end
  6. customize views $>rails generate devise:views create app/views/devise create app/views/devise/confirmations/new.html.erb create

    app/views/devise/mailer/confirmation_instructions.html.erb create app/views/devise/mailer/reset_password_instructions.html.erb create app/views/devise/mailer/unlock_instructions.html.erb create app/views/devise/passwords/edit.html.erb create app/views/devise/passwords/new.html.erb create app/views/devise/registrations/edit.html.erb create app/views/devise/registrations/new.html.erb create app/views/devise/sessions/new.html.erb create app/views/devise/shared/_links.erb create app/views/devise/unlocks/new.html.erb