Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Standup 3.21.2011: Deactivating users in devise

Interesting Things

All strategies that inherit from Devise::Strategies::Authenticatable (which may be all right now) check for To deactivate a user, just add an active column to User model, and a message to present with inactive_message:

# User model

def active?

def inactive_message
  "Sorry, this account has been deactivated."

and to test:

# Any session controller spec

it "should throw an error with an inactive user" do
  user = Factory.create(:user, :password => "password") = false!

  error = catch(:warden) do
    post :create, :user => {:username => user.username, :password => "password"}

  error[:message].should =~ /deactivated/

  1. Alex Rojo says:

    Hello, i’ve tried this and it doesn’t work for me. I’m using devise (2.1.2). Any suggestion?

  2. Ben says:

    Hey Alex, I’m seeing the same problem. It looks like Devise 2.1.2 uses “active_for_authentication?” See

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *