Skip to content

How To: Upgrade to Devise 2.0

rurounijones edited this page Jan 8, 2012 · 15 revisions

Devise 2.0 is actually a small release aimed mainly to clean up Devise source code. With time, Devise added new behaviors but, since we had to maintain backwards compatibility, we could not deprecate the old behaviors. Devise 2.0 finally deprecates such old behaviors.

The difficulty to migrate to Devise 2.0 will depend on when you started developing your application. If you started a long time ago, you will probably need to add or remove columns from your database schema. If recently, you will just need to rename a few configuration options.

Before upgrading to Devise 2.0, be sure that your application is fine running on Devise 1.5.x.

Devise 2.0 provides two main features:

  • Support for e-mail reconfirmation when it changes. You can benefit from this change by setting Devise.reconfirmable to true and adding an unconfirmed_email column to your Devise models;
  • Deprecation of Devise's migration methods. All applications migrating to Devise 2.0 will have to upgrade their original Devise migrations. This page describes exactly how to do it;

Besides that, a few configuration options were renamed or removed:

  • Devise.remember_across_browsers is no longer effective. You can simply remove it;
  • Devise.confirm_within was renamed to Devise.allow_unconfirmed_access_for;
  • Devise.stateless_token was removed. If you want to have stateless tokens, simply do config.skip_session_storage << :token_auth in your initializer;

Finally, in case you started using Devise in your app some time ago, your schema may be out of date and you need to update it:

  • Devise now always uses the password salt as basis for the remember token. You can remove the remember_token column from your models and set Devise.use_salt_as_remember_token to true;
  • Devise now requires you to have a reset_password_sent_at column. Please add it to your Devise models and set Devise.reset_password_within to an interval (like 6 hours);

Luckily, those are all changes you need to do to have your app successfully running on Devise 2.0. Welcome aboard!

Clone this wiki locally