基本的には、Devise の25 行目あたりを変更しますConfirmationsController
。
これは、アクション内のそのステートメントshow
の「ハッピー パス」を心ゆくまで変更するアクションをオーバーライドする必要があることを意味します。if
show
class ConfirmationsController < Devise::ConfirmationsController
def new
super
end
def create
super
end
def show
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
if resource.errors.empty?
set_flash_message(:notice, :confirmed) if is_navigational_format?
sign_in(resource_name, resource)
respond_with_navigational(resource){ redirect_to confirmation_getting_started_path }
else
respond_with_navigational(resource.errors, :status => :unprocessable_entity){ render_with_scope :new }
end
end
end
そして、そのためのスコープ付きルート (ビューとアクションを登録コントローラーに入れましたが、それを何にでも変更できます):
devise_for :users, controllers: { confirmations: 'confirmations' }
devise_scope :user do
get '/confirmation-getting-started' => 'registrations#getting_started', as: 'confirmation_getting_started'
end
デフォルトのshow
アクションは保護されたafter_confirmation_path_for
メソッドを参照しているため、別のオプションとして、そのメソッドが返すものを変更することもできます。