title: How to redirect to some other page after user confirmed
body: <p>I am using Rails 3.2.13 and Devise 3.2.4. After user registration, the confirmation link is generated:</p>
  
  <pre><code>localhost:3000/users/confirmation?confirmation_token=HpPHitLtV3CnLy2z1ZmQ
  </code></pre>
  
  <p>I want to redirect to the <code>mentors/new</code> action after clickin on the confirmation link, but after confirmation it redirects to <code>/users/sign_in</code> which I don't want. </p>
  
  <p>This is my code so far:</p>
  
  <p>Routes:</p>
  
  <pre><code>devise_for :users
  devise_for :users, :controllers =&gt; { :confirmations =&gt; 'confirmations' }
  </code></pre>
  
  <p>Created Confirmations controller and overrides from Devise::ConfirmationsController:</p>
  
  <pre><code>class ConfirmationsController &lt; Devise::ConfirmationsController
    protected
  
  def after_confirmation_path_for(resource_name, resource)
    if resource.has_role? :user
      redirect_to new_mentor_path("account_id")
    else
      root_path
    end
  end
  end
  </code></pre>
  
  <p>In ConfirmationsController, maybe I have to add some extra code.</p>
  
  <p>In application controller I have this code which takes me to the <code>mentor/student</code> home after a successfull sign-in:</p>
  
  <pre><code>def after_sign_in_path_for(resource_or_scope)
  if resource_or_scope.is_a?(User)
    if current_user.user_type == "mentor"
      home_mentors_path(:account_id =&gt; current_user.account_id)
    else
      home_students_path(:account_id =&gt; current_user.account_id)
    end
  end
  </code></pre>
  
  <p>end</p>
  
  <pre><code>def after_sign_up_path_for(resource_or_scope)
    root_path
  end
  </code></pre>
  
  <p>Generally the logic is like this, but I do not understand how to do this with Devise:</p>
  
  <pre><code>def activate
    @user = User.where("activation_code = ?","#{params[:id]}").first
    if !@user.blank?
     if @user.created_at &lt; 24.hours.ago
       if @user and @user.activate
        cookies[:user_id]=@user.id
        if @user.user_type == "student"
          redirect_to new_student_path
        else
          redirect_to new_mentor_path
        end
      else
        @user.destroy
        redirect_to "/"
      end
    else
      @user.destroy
      redirect_to "/"
    end
  else
    redirect_to "/"
  end
  </code></pre>
  
  <p>end</p>