Last active
August 29, 2015 14:26
-
-
Save mnishiguchi/d914208d9a6e5bd9fda5 to your computer and use it in GitHub Desktop.
Deviseのconfirmable - 確認メールのリンクをクリックしたら即サインインする ref: http://qiita.com/mnishiguchi/items/85df424577326f4207b1
This file contains hidden or 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
| # Override | |
| class ConfirmationsController < Devise::ConfirmationsController | |
| def show | |
| self.resource = resource_class.confirm_by_token(params[:confirmation_token]) | |
| yield resource if block_given? | |
| if resource.errors.empty? | |
| set_flash_message(:notice, :confirmed) if is_flashing_format? | |
| sign_in(resource) # この一行を加えるのみ | |
| respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } | |
| else | |
| respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render :new } | |
| end | |
| end | |
| end |
This file contains hidden or 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
| Rails.application.routes.draw do | |
| # ... | |
| devise_for :users, controllers: { confirmations: 'confirmations' } | |
| # ... | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment