title: Devise + omniauth routing problem on Heroku
body: <p>I've been pulling my hair for hours on this one... I have a Devise and omniauth setup that allows users to log in with their Facebook accounts. I am using the following gem versions:</p>
  
  <pre><code>Installing devise (1.4.7)
  Installing oauth2 (0.4.1)
  Installing oa-oauth (0.2.6)
  Installing omniauth (0.2.6)
  </code></pre>
  
  <p>among others and have the app id and secret in my Devise initializer:</p>
  
  <pre><code>config.omniauth :facebook, 'app_id', 'app_secret',
            {:scope =&gt; 'email, offline_access', :client_options =&gt; {:ssl =&gt; {:verify =&gt; false}}}
  </code></pre>
  
  <p>Though I also tried this with no luck:</p>
  
  <pre><code>config.omniauth :facebook, 'app_id', 'app_secret',
            # {:scope =&gt; 'email, offline_access', :client_options =&gt; {:ssl =&gt; {:ca_file =&gt; '/usr/lib/ssl/certs/ca-certificates.crt'}}}
  </code></pre>
  
  <p>I have the :omniauthable directive in my user model, and I define my own callback controller in the routes file:</p>
  
  <pre><code>devise_for :users, :controllers =&gt; { :omniauth_callbacks =&gt; 'user/authentications', :registrations =&gt; 'registrations' }
  
  root :to =&gt; 'pages#home'
  </code></pre>
  
  <p>And I also tried adding this to the routes file with no luck:</p>
  
  <pre><code>get '/users/auth/:provider' =&gt; 'user/authentications#passthru'
  </code></pre>
  
  <p>Here is my authentications controller:</p>
  
  <pre><code>class AuthenticationsController &lt; Devise::OmniauthCallbacksController
    def index
      @authentications = current_user.authentications if current_user
    end
  
    def facebook
      omniauth = request.env["omniauth.auth"]
      authentication = Authentication.find_by_provider_and_uid(omniauth['provider'], omniauth['uid'])
      if authentication
        flash[:notice] = "Signed in successfully."
        sign_in_and_redirect(:user, authentication.user)
      elsif current_user
        current_user.authentications.create!(:provider =&gt; omniauth['provider'], :uid =&gt; omniauth['uid'])
        flash[:notice] = "Authentication successful."
        redirect_to authentications_url
      else
        user = User.new
        user.apply_omniauth(omniauth)
        if user.save
          flash[:notice] = "Signed in successfully."
          sign_in_and_redirect(:user, user)
        else
          session[:omniauth] = omniauth.except('extra')
          redirect_to new_user_registration_url
        end
      end
    end
  
    def passthru
      render :file =&gt; "#{Rails.root}/public/404.html", :status =&gt; 404, :layout =&gt; false
    end
  
    def destroy
      @authentication = current_user.authentications.find(params[:id])
      @authentication.destroy
      flash[:notice] = "Successfully destroyed authentication."
      redirect_to authentications_url
    end
  end
  </code></pre>
  
  <p>And my Facebook log in link:</p>
  
  <p>&lt;%= link_to image_tag('/assets/facebook_32.png'), omniauth_authorize_path(resource_name, :facebook)%></p>
  
  <p>This all works great locally, but if I try to log in with my Facebook account when my app is deployed to Heroku, I get the following in my log and I'm directed to the 404 page:</p>
  
  <pre><code>2011-09-23T03:26:31+00:00 app[web.1]: ActionController::RoutingError (uninitiali
  zed constant User::AuthenticationsController):
  </code></pre>
  
  <p>I tried resetting my database, but that didn't help either.</p>
  
  <p>Here are my routes from Heroku:</p>
  
  <pre><code>        new_user_session GET    /users/sign_in(.:format)               {:action=
  &gt;"new", :controller=&gt;"devise/sessions"}
              user_session POST   /users/sign_in(.:format)               {:action=
  &gt;"create", :controller=&gt;"devise/sessions"}
      destroy_user_session GET    /users/sign_out(.:format)              {:action=
  &gt;"destroy", :controller=&gt;"devise/sessions"}
    user_omniauth_callback        /users/auth/:action/callback(.:format) {:action=
  &gt;/facebook/, :controller=&gt;"user/authentications"}
             user_password POST   /users/password(.:format)              {:action=
  &gt;"create", :controller=&gt;"devise/passwords"}
         new_user_password GET    /users/password/new(.:format)          {:action=
  &gt;"new", :controller=&gt;"devise/passwords"}
        edit_user_password GET    /users/password/edit(.:format)         {:action=
  &gt;"edit", :controller=&gt;"devise/passwords"}
                           PUT    /users/password(.:format)              {:action=
  &gt;"update", :controller=&gt;"devise/passwords"}
  cancel_user_registration GET    /users/cancel(.:format)                {:action=
  &gt;"cancel", :controller=&gt;"registrations"}
         user_registration POST   /users(.:format)                       {:action=
  &gt;"create", :controller=&gt;"registrations"}
     new_user_registration GET    /users/sign_up(.:format)               {:action=
  &gt;"new", :controller=&gt;"registrations"}
    edit_user_registration GET    /users/edit(.:format)                  {:action=
  &gt;"edit", :controller=&gt;"registrations"}
                           PUT    /users(.:format)                       {:action=
  &gt;"update", :controller=&gt;"registrations"}
                           DELETE /users(.:format)                       {:action=
  &gt;"destroy", :controller=&gt;"registrations"}
                      root        /                                      {:control
  ler=&gt;"pages", :action=&gt;"home"}
  </code></pre>
  
  <p>Any help is greatly appreciated. Please let me know if you need any other info. I know it's something small, but I feel like I've tried a thousand different things and nothing has worked.</p>