Created
October 28, 2013 21:49
-
-
Save murdoch/7205439 to your computer and use it in GitHub Desktop.
Devise allow unconfirmed access to site, but force confirmation for certain actions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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