Routing issue, matching a param as action

I have the following routes :

match ‘/auth/:provider/callback’, to: ‘omniauth_callbacks#create’

I can test the :provider in the create action …

is there any way to directly match to an action with the :provider
name ?

It seems in some cases I can use the redirect

match ‘/auth/:provider/callback’, :to => redirect {|params| “/
omniauth_callbacks/#{params[:provider]}” }

but not in this case , as the redirect will change the request , and
I’ll not be able to check for request.env[“omniauth.auth”]

so I resolved to write one match for each :provider .
match ‘/auth/google_oauth2/callback’, to:
match ‘/auth/facebook/callback’, to: ‘omniauth_callbacks#facebook’
match ‘/auth/twitter/callback’, to: ‘omniauth_callbacks#twitter’

You could do something like this:

match ‘/auth/:provider/callback’, to: ‘omniauth_callbacks#all_callbacks’

class OmniauthCallbacksController
def all_callbacks

def facebook


def twitter


def method_missing(method_name, *args, &block)
#do some stuff

2012/10/7 Erwin [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs