Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ol - fix recognize_path for not being able to parse engine routes in … #21494

Closed

Conversation

orlandoAppfolio
Copy link

…main app

@orlandoAppfolio
Copy link
Author

In the main_app, Rails.application.routes.recognize_path('path/in/engine')
e.g. we have a Dummy engine and OccupancyYearsController

Rails.application.routes.recognize_path('dummy/occupancy_years')

will throw an exception

ActionController::RoutingError: A route matches "/dummy/occupancy_years", but references missing controller: DummyController
from /Users/user_name/.rvm/gems/ruby-2.2.3/gems/actionpack-4.0.12/lib/action_dispatch/routing/route_set.rb:711:in `block in recognize_path'

though

Dummy::Engine.routes.recognize_path('occupancy_years')

works just fine giving
{:action=>"index", :controller=>"dummy/occupancy_years"}

recognize_path calls #recognize https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/journey/router.rb#L57

where as normal request calls #serve https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/journey/router.rb#L28

Trying to make normal request and recognize_path#recognize consistent

@rafaelfranca
Copy link
Member

r? @tenderlove I remember you want to deprecated recognize_path to public consumption so this may concern you.

@rafaelfranca
Copy link
Member

recognize_path is private API and should not be used in applications.

@tolgap
Copy link

tolgap commented Nov 15, 2018

@rafaelfranca @tenderlove what is the workaround for this? I want to parse the request.referer into a route. I need to whitelist/blacklist certain URLs from being redirected to when signing in users.

If I were to store the request.fullpath on each request, this would not work when users go back in their browsers (as browsers dont send anything to the server when using the back button). So my only reliable option is to use request.referer.

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

Successfully merging this pull request may close these issues.

None yet

5 participants