main_app.user_omniauth_authorize_path throws error #1843

Closed
apraditya opened this Issue May 11, 2012 · 4 comments

Projects

None yet

3 participants

@apraditya

I setup omniauth to Facebook described in OmniAuth:-Overview wiki page and it works great until I use a rails engine. If I use user_omniauth_authorize_path inside the views from the engine, it doesn't throw any error like the rest of the devise paths (eg. new_user_session_path). Instead, it generates a wrong URL.

If i use main_app.user_omniauth_authorize_path it throws the following error in all views:

undefined method `user_omniauth_authorize_path' for #<ActionDispatch::Routing::RoutesProxy:0x007ffee7d836d0>

I'm using devise-2.0.4, omniauth-facebook-1.3.0 and Rails 3.2.2 on ruby 1.9.3p194, on OS X. I tried to upgrade to devise 2.1.0.rc2 and still have the same issue.

Owner

The omniauth authorize helpers are not real route, they are simply created by Devise. So you should be able to invoke them from wherever you want and you must not invoke them in the main app. Here is their implementation:

https://github.com/plataformatec/devise/blob/master/lib/devise/omniauth/url_helpers.rb

Where are your routes mounted, in the app or in the engine? Which result are you getting and which result do you expect instead?

Thank you for the quick response! The routes are in the app.

mount Forem::Engine, at: "/forum/"

I'm getting http://localhost:3000/**forum**/users/auth/facebook while it should be http://localhost:3000/users/auth/facebook (without 'forum').

Owner

Yeah... for now I will ask you to generate the URL by hand. I think we should probably generate fake routes for these endpoints in the router so it works without extra hassle.

@josevalim josevalim closed this in b1633f2 Jun 16, 2012
sharp commented Jan 7, 2013
<header>
    <nav>
        <% if user_signed_in? %>
            <%= link_to current_user.email, main_app.edit_user_registration_path %>
            | <%= link_to "Sign out", main_app.destroy_user_session_path, :method => :delete %>
            <% if current_user.forem_admin %>
                | <%= link_to "Administrate", forem.admin_root_url %>
            <% end %>
        <% else %>
            <%= link_to "Sign up", main_app.new_user_registration_path %>
            | <%= link_to "Sign in", main_app.new_user_session_path %>
        <% end %>
    </nav>
</header>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment