Skip to content

Instantly share code, notes, and snippets.

@murdoch
Created October 28, 2013 21:49
Show Gist options
  • Save murdoch/7205439 to your computer and use it in GitHub Desktop.
Save murdoch/7205439 to your computer and use it in GitHub Desktop.
Devise allow unconfirmed access to site, but force confirmation for certain actions
Devise by default has a configuration named:
config.allow_unconfirmed_access_for
You can set it in your devise initializer and it will allow the user to access any page, any time, while still unconfirmed.
Then, for the pages you require confirmation, you can simply add a before filter:
before_filter :only_confirmed
def only_confirmed
redirect_to "/", notice: "NOPE" unless current_user.confirmed?
end
Yay.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment