README.rdoc in devise-0.6.0 vs README.rdoc in devise-0.6.1

- old
+ new

@@ -11,10 +11,11 @@ * Authenticatable: responsible for encrypting password and validating authenticity of a user while signing in. * Confirmable: responsible for verifying whether an account is already confirmed to sign in, and to send emails with confirmation instructions. * Recoverable: takes care of reseting the user password and send reset instructions. * Rememberable: manages generating and clearing token for remember the user from a saved cookie. +* Timeoutable: expires sessions without activity in a certain period of time. * Validatable: creates all needed validations for email and password. It's totally optional, so you're able to to customize validations by yourself. There's an example application using Devise at http://github.com/plataformatec/devise_example . == Dependencies @@ -25,11 +26,11 @@ All gems are on gemcutter, so you need to add gemcutter to your sources if you haven't yet: sudo gem sources -a http://gemcutter.org/ -Install warden gem if you don't have it installed (requires 0.5.2 or higher): +Install warden gem if you don't have it installed (requires 0.6.4 or higher): sudo gem install warden Install devise gem: @@ -65,37 +66,40 @@ add_index :your_table, :reset_password_token # for recoverable Now let's setup a User model adding the devise line to have your authentication working: class User < ActiveRecord::Base - devise + devise :authenticatable end -This line adds devise authenticatable automatically for you inside your User class. Devise don't rely on _attr_accessible_ or _attr_protected_ inside its modules, so be sure to setup what attributes are accessible or protected in your model. +This line adds devise authenticatable inside your User class. Devise don't rely on _attr_accessible_ or _attr_protected_ inside its modules, so be sure to setup what attributes are accessible or protected in your model. You could also include the other devise modules as below: # Include only authenticatable stuff devise :authenticatable # Include authenticatable + confirmable - devise :confirmable + devise :authenticatable, :confirmable # Include authenticatable + recoverable + rememberable - devise :recoverable, :rememberable + devise :authenticatable, :recoverable, :rememberable + # Include authenticatable + timeoutable + devise :authenticatable, :timeoutable + # Include all of them devise :all # Include all except recoverable devise :all, :except => :recoverable Note that validations aren't added by default, so you're able to customize it. In order to have automatic validations working just include :validatable. == Model configuration -In addition to :except, you can provide :pepper, :stretches, :encryptor, :authentication_keys, :confirm_within and :remember_for as options to devise method. +In addition to :except, you can provide :pepper, :stretches, :encryptor, :authentication_keys, :confirm_within, :remember_for and :timeout as options to devise method. All those options are described in "config/initializers/devise.rb", which is generated when you invoke `ruby script/generate devise_install` in your application root. == Routes @@ -138,10 +142,14 @@ Finally, if you are using confirmable or recoverable, you also need to setup default url options for the mailer. Here's is the configuration for development: DeviseMailer.sender = "no-reply@yourapp.com" config.action_mailer.default_url_options = { :host => 'localhost:3000' } +== Views + +By default devise will use the same views for all scopes/roles you have. But what if you need so different views to each of them? Devise also has an easy way to accomplish it: just setup :scoped_views to true inside your devise config file, and you will be able to have views based on scope like 'sessions/users/new' and 'sessions/admin/new'. If no view is found within the scope, Devise will fallback to the default view. + == Tidying up Devise let's you setup as many roles as you want, so let's say you already have this User model and also want an Admin model with the same authentication stuff, but not confirmation or password recovery. Just follow the same steps: # Create a migration with the required fields @@ -235,10 +243,10 @@ Devise implements encryption strategies for Clearance, Authlogic and Restful-Authentication. To make use of it set the desired encryptor in the encryptor initializer config option. You might also need to rename your encrypted password and salt columns to match Devises's one (encrypted_password and password_salt). == Other ORMs -Devise was made to work from scratch with ActiveRecord. However it currently supports MongoMapper as well. +Devise was made to work from scratch with ActiveRecord. However it currently supports DataMapper and MongoMapper as well. To use it, just set Devise.orm or configure it in the initialization file (which is created with devise_install). == TODO Please refer to TODO file.