SlideShare a Scribd company logo
Devise Taking care of your users Andreas Bjärlestam 2011-02-22
Andreas Bjärlestam mailto:andreas@bjarlestam.com http://twitter.com/bjarlestam
So you are building a site with rails?
Hopefully you will have some users lining up...
They will probably f#&k things up USER USER
This could require quite some coding Signup page Login page Account confirmation mails Password reset mails Password reset page Checks and redirects
You?
What to do?
DEVISE can do it!
DEVISE User authentication User signup Account confirmaiton Password recovery Remembering via cookie Session expiration Account locking http://github.com/plataformatec/devise
Lets code…
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
Create a User model $>rails generate devise User $>rake db:migrate
Test it $>rails server $>open http://localhost:3000/users/sign_up $>open http://localhost:3000/users/sign_in $>open http://localhost:3000/users/sign_out
 
What happened?
configuration Configured routes  config/routes.rb devise_for :users Configuration file and localization config/initializers/devise.rb config/initializers/locales/devise.en.yml
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
helpers available before_filter :authenticate_user! user_signed_in? current_user
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
 
Attributions http://www.flickr.com/photos/weelakeo/3815108314/ http://www.flickr.com/photos/nikio/3899114449/ http://www.flickr.com/photos/zigazou76/3636704536/ http://www.flickr.com/photos/myklroventine-events/3832058915/ http://www.flickr.com/photos/cokaigne/1401246909/ http://www.flickr.com/photos/alpha/5434014952 http://www.flickr.com/photos/alpha/5433405433

More Related Content

PPTX
Writer Mary Klest
ODP
Mechanize at the Ruby Drink-up of Sophia, November 2011
ODP
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
PDF
Shortcodes: WordUp Pompey! Feb-2012
PDF
Alternative Uses of WP
PDF
Customizing Your WooCommerce Store
PDF
Web Resources
PDF
_s v. genesis
Writer Mary Klest
Mechanize at the Ruby Drink-up of Sophia, November 2011
Widgets: Making Your Site Great and Letting Others Help - WordCamp Victoria
Shortcodes: WordUp Pompey! Feb-2012
Alternative Uses of WP
Customizing Your WooCommerce Store
Web Resources
_s v. genesis

What's hot (10)

DOCX
Dokumen Blog
PDF
Custom Fields & Custom Metaboxes Overview
PPTX
Designing web pages html videos
PPT
Designing Firefox Themes
ODP
Worry free web development
DOCX
Script membuat animasi di blog yeny
PPT
From jQuery to App Store in 30 Minutes
PDF
Quick ref capybara
PDF
HTML+CSS: how to get started
Dokumen Blog
Custom Fields & Custom Metaboxes Overview
Designing web pages html videos
Designing Firefox Themes
Worry free web development
Script membuat animasi di blog yeny
From jQuery to App Store in 30 Minutes
Quick ref capybara
HTML+CSS: how to get started
Ad

Similar to Devise (20)

PPT
Please dont touch-3.6-jsday
ZIP
Merb Router
PPTX
5 Reasons To Love CodeIgniter
PPT
EPiServer Web Parts
PDF
Shifting Gears
KEY
Working Effectively With Legacy Code
PPT
Filling the HTML5 Gaps with Polyfills and Shims
PDF
Mojolicious, real-time web framework
PDF
Merb Pluming - The Router
PPT
CSS Best practices
PDF
Node.js & Twitter Bootstrap Crash Course
PPT
Grails and Dojo
PDF
Death of a Themer
PPT
Boston Computing Review - Ruby on Rails
PPT
What I brought back from Austin
PPTX
Moving applications to the cloud
PPT
Using a CSS Framework
ODP
Ramaze - The Underrated Ruby Web Framework
ODP
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
PDF
Front End Development for Back End Developers - Denver Startup Week 2017
Please dont touch-3.6-jsday
Merb Router
5 Reasons To Love CodeIgniter
EPiServer Web Parts
Shifting Gears
Working Effectively With Legacy Code
Filling the HTML5 Gaps with Polyfills and Shims
Mojolicious, real-time web framework
Merb Pluming - The Router
CSS Best practices
Node.js & Twitter Bootstrap Crash Course
Grails and Dojo
Death of a Themer
Boston Computing Review - Ruby on Rails
What I brought back from Austin
Moving applications to the cloud
Using a CSS Framework
Ramaze - The Underrated Ruby Web Framework
10 Things You're Not Doing [IBM Lotus Notes Domino Application Development]
Front End Development for Back End Developers - Denver Startup Week 2017
Ad

More from Andreas Bjärlestam (7)

PDF
Climate compensate with a pull request (2).pdf
PPTX
Agile performance testing
PPTX
SPDY - or maybe HTTP2.0
PPTX
Mobile web with jQuery Mobile
PPT
Introduction to JAX-RS
Climate compensate with a pull request (2).pdf
Agile performance testing
SPDY - or maybe HTTP2.0
Mobile web with jQuery Mobile
Introduction to JAX-RS

Recently uploaded (20)

PDF
NewMind AI Weekly Chronicles - August'25-Week II
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
Approach and Philosophy of On baking technology
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
August Patch Tuesday
PPTX
OMC Textile Division Presentation 2021.pptx
PDF
Encapsulation theory and applications.pdf
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
Machine Learning_overview_presentation.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Empathic Computing: Creating Shared Understanding
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
A Presentation on Artificial Intelligence
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
NewMind AI Weekly Chronicles - August'25-Week II
A comparative analysis of optical character recognition models for extracting...
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Approach and Philosophy of On baking technology
Per capita expenditure prediction using model stacking based on satellite ima...
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
August Patch Tuesday
OMC Textile Division Presentation 2021.pptx
Encapsulation theory and applications.pdf
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
Machine Learning_overview_presentation.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Empathic Computing: Creating Shared Understanding
Digital-Transformation-Roadmap-for-Companies.pptx
A Presentation on Artificial Intelligence
MIND Revenue Release Quarter 2 2025 Press Release
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
gpt5_lecture_notes_comprehensive_20250812015547.pdf

Devise

  • 1. Devise Taking care of your users Andreas Bjärlestam 2011-02-22
  • 2. Andreas Bjärlestam mailto:andreas@bjarlestam.com http://twitter.com/bjarlestam
  • 3. So you are building a site with rails?
  • 4. Hopefully you will have some users lining up...
  • 5. They will probably f#&k things up USER USER
  • 6. This could require quite some coding Signup page Login page Account confirmation mails Password reset mails Password reset page Checks and redirects
  • 10. DEVISE User authentication User signup Account confirmaiton Password recovery Remembering via cookie Session expiration Account locking http://github.com/plataformatec/devise
  • 12. Create a rails project $>rails new devise_test $>cd devise_test $>gem install devise $>echo &quot;gem 'devise'&quot; >> Gemfile $>rails generate devise:install $>cat config/routes.rb | sed s/'# root :to'/'root :to'/ >> config/routes.rb
  • 13. Create a User model $>rails generate devise User $>rake db:migrate
  • 14. Test it $>rails server $>open http://localhost:3000/users/sign_up $>open http://localhost:3000/users/sign_in $>open http://localhost:3000/users/sign_out
  • 15.  
  • 17. configuration Configured routes config/routes.rb devise_for :users Configuration file and localization config/initializers/devise.rb config/initializers/locales/devise.en.yml
  • 18. 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
  • 19. helpers available before_filter :authenticate_user! user_signed_in? current_user
  • 20. 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
  • 21.  
  • 22. Attributions http://www.flickr.com/photos/weelakeo/3815108314/ http://www.flickr.com/photos/nikio/3899114449/ http://www.flickr.com/photos/zigazou76/3636704536/ http://www.flickr.com/photos/myklroventine-events/3832058915/ http://www.flickr.com/photos/cokaigne/1401246909/ http://www.flickr.com/photos/alpha/5434014952 http://www.flickr.com/photos/alpha/5433405433