Skip to content

Instantly share code, notes, and snippets.

@JoeWoodward
Created December 15, 2011 22:06
Show Gist options
  • Save JoeWoodward/1483126 to your computer and use it in GitHub Desktop.
Save JoeWoodward/1483126 to your computer and use it in GitHub Desktop.
#controller
def activate
if @user = User.load_from_activation_token(params[:activation_token])
@user.inactive = true
@user.activate!
login(@user.email, @user.password)
else
redirect_to login_path, :alert => 'Account has been activated already, please login'
end
end
#User.rb
attr_accessor :inactive
validates_presence_of :password, :if => :should_be_validated?
def should_be_validated?
inactive
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment