views:

37

answers:

1

I'm trying to build a new rails 3 app from scratch using OmniAuth. Currently I just have a completely empty app, where I've added omniauth to the Gemfile, and added a omniauth.rb in config/initializers that looks like this:

Rails.application.config.middleware.use OmniAuth::Builder do
  provider :facebook, 'APP_ID', 'APP_SECRET'
end

(Except with the proper app id and secret instead of the placeholders of course.)

This seems to work when running from my development machine using Webrick, however facebook gives an error since localhost:3000 is not registered as an application. So I upload it to the production server for testing. Here the request seems to bypass the rack layer completely and ends up in rails which throws a RoutingError since there's no route called /auth/facebook defined in routes.rb.

The server runs apache 2.2, ruby 1.8.7, rails 3.0.1, rack 1.2 and passenger 3.0.0. Is there anything obvious I'm missing?

Btw, the app is installed to a sub-url, i.e. http://www.mydomain.net/myapp

A: 

Found it out myself:

Changed the code to:

Rails.application.config.middleware.use OmniAuth::Builder do
  configure do |config|
    config.path_prefix = '/myapp/auth' if RAILS_ENV == 'production'
  end

  provider :facebook, 'APP_ID', 'APP_SECRET'
end

Now it works like a charm.

harald