title: Why isn't Devise + Omniauth callback hitting the correct controller?
body: <p>Can anyone help me get to the bottom of this problem?</p>
  
  <p>I'm using Devise + Omniauth in a Rails 3.2 app. What I want to know is, what's happening behind the scenes with Devise's <code>user_omniauth_authorize_path(provider)</code> method.</p>
  
  <p>I've had a dig through rake routes and the gem's source, but I can't see anything obvious that would cause the issue I'm having.</p>
  
  <p>I assume this method simply calls the provider's signin url (e.g. Twitter) and then returns to the callback path defined in routes.rb.</p>
  
  <p>In my routes.rb I have </p>
  
  <pre><code>devise_for :users, :controllers =&gt; { :omniauth_callbacks =&gt; 'users/omniauth_callbacks'}
  
  devise_scope :user do
      get '/users/auth/:provider' =&gt; 'users/omniauth_callbacks#passthru'
  end
  </code></pre>
  
  <p>In users/omniauth_callbacks_controller.rb I have</p>
  
  <pre><code>def twitter
      render :text =&gt; "This works" 
  end
  
  def passthru
      render :text =&gt; "This doesn't work"
  end
  </code></pre>
  
  <p>In a view I have <code>&lt;%= link_to "Twitter", user_omniauth_authorize_path(:twitter) %&gt;</code>. Clicking this link goes to Twitter where I can log in, but upon return to my app I get an error "You are already signed in".</p>
  
  <p>I can't work out how or why this error is being generated. I should only be seeing "This works" or "This doesn't work".</p>
  
  <p>I also have a Facebook provider set up in exactly the same way, and this works as expected.</p>
  
  <p>If I replace Devise's omniauth link with <code>&lt;a href="/users/auth/twitter"&gt;Twitter&lt;/a&gt;</code> then I get "This works".</p>
  
  <p>So this solves my issue, but its not ideal and I'd like to know why.</p>
  
  <p>Can anyone shed any light?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Rake routes looks like this:</p>
  
  <pre><code>user_omniauth_callback        /users/auth/:action/callback(.:format)                       users/omniauth_callbacks#(?-mix:twitter|facebook)
  </code></pre>