title: Devise Confirmation invalid on first send
body: <p>I have a Rails 4 app with Devise 3.2.2 using <code>:confirmable</code>, and am running into an issue with it sending invalid confirmation tokens, but <strong>only the first time</strong>. After you resend the confirmation token, the link works.</p>
  
  <p>The relevant routes:</p>
  
  <pre><code>devise_for :users, skip: [:sessions, :passwords, :confirmations, :unlocks, :registrations, :invitations]
  as :user do
    ...
    # joining
    get   '/register' =&gt; 'devise/registrations#new',    as: 'new_user_registration'
    post  '/register' =&gt; 'devise/registrations#create', as: 'user_registration'
    ...
  end
  </code></pre>
  
  <p>...and the mail template in question:</p>
  
  <pre><code>&lt;p&gt;Welcome &lt;%= @email %&gt;!&lt;/p&gt;
  
  &lt;p&gt;You can confirm your account email through the link below:&lt;/p&gt;
  
  &lt;p&gt;&lt;%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token =&gt; @token) %&gt;&lt;/p&gt;
  </code></pre>
  
  <p>As far as I can tell, everything is pretty standard fare, and the fact that it only fails when initially creating and not on the resend is rather confusing.</p>
  
  <p><strong>--Update--</strong></p>
  
  <p>When clicking on the link, I get the following in my dev log:</p>
  
  <pre><code>Started GET "/account/confirm?confirmation_token=3bQP-EvYJPv74s9AMz63" for 127.0.0.1 at 2014-02-07 12:26:10 -0500
  Processing by Users::ConfirmationsController#show as HTML
    Parameters: {"confirmation_token"=&gt;"3bQP-EvYJPv74s9AMz63"}
    User Load (0.4ms)  SELECT "users".* FROM "users" WHERE "users"."confirmation_token" = 'e191b48746f15014beb32073f08de3c7aa13a2282216f089fa71d083901b3dca' ORDER BY "users"."id" ASC LIMIT 1
    Rendered devise/shared/_links.slim (1.2ms)
    Rendered devise/confirmations/new.html.slim within layouts/devise (7.0ms)
    Rendered layouts/_jquery.slim (1.0ms)
  Completed 200 OK in 32ms (Views: 23.4ms | ActiveRecord: 0.4ms)
  </code></pre>
  
  <p>The referenced controller is:</p>
  
  <pre><code>class Users::ConfirmationsController &lt; Devise::ConfirmationsController
  
    protected
  
    def after_confirmation_path_for(resource_name, resource)
      if signed_in?
        signed_in_root_path(resource)
      else
        new_session_path(resource_name, email: resource.email)
      end
    end
  
  end
  </code></pre>
  
  <p><strong>-- Update 2 --</strong></p>
  
  <p>The following is a gist of the logs from the entire signup process:
  <a href="https://gist.github.com/jbender/bbe079c2dd3fa2d1e664" rel="nofollow">https://gist.github.com/jbender/bbe079c2dd3fa2d1e664</a></p>