Skip to content

Instantly share code, notes, and snippets.

@mnishiguchi
Last active August 29, 2015 14:26
Show Gist options
  • Select an option

  • Save mnishiguchi/d914208d9a6e5bd9fda5 to your computer and use it in GitHub Desktop.

Select an option

Save mnishiguchi/d914208d9a6e5bd9fda5 to your computer and use it in GitHub Desktop.
Deviseのconfirmable - 確認メールのリンクをクリックしたら即サインインする ref: http://qiita.com/mnishiguchi/items/85df424577326f4207b1
# 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
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