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 ?>> match ''/auth/:provider/callback'', to: ''omniauth_callbacks#(:provider)'' ...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
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: ''omniauth_callbacks#google_oauth2'' match ''/auth/facebook/callback'', to: ''omniauth_callbacks#facebook'' match ''/auth/twitter/callback'', to: ''omniauth_callbacks#twitter'' On 7 oct, 11:07, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote:> 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 ? > > > > > > > > >> match ''/auth/:provider/callback'', to: ''omniauth_callbacks#(:provider)'' ...-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Ignacio Piantanida
2012-Oct-07 20:24 UTC
Re: Re: routing issue, matching a param as action
You could do something like this: match ''/auth/:provider/callback'', to: ''omniauth_callbacks#all_callbacks'' class OmniauthCallbacksController def all_callbacks send(params[:provider]) end def facebook .... end def twitter ... end def method_missing(method_name, *args, &block) #do some stuff end end 2012/10/7 Erwin <yves_dufour-ee4meeAH724@public.gmane.org>> 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: > ''omniauth_callbacks#google_oauth2'' > match ''/auth/facebook/callback'', to: ''omniauth_callbacks#facebook'' > match ''/auth/twitter/callback'', to: ''omniauth_callbacks#twitter'' > > > On 7 oct, 11:07, Erwin <yves_duf...-ee4meeAH724@public.gmane.org> wrote: > > 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 ? > > > > > > > > > > > > > > > > >> match ''/auth/:provider/callback'', to: > ''omniauth_callbacks#(:provider)'' ... > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > For more options, visit https://groups.google.com/groups/opt_out. > > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.