Closed ahorner closed 9 years ago
I'd actually like to see if we can determine a routing error without depending on the name of the action. I'll do some poking around and let you know what I come up with.
Sounds good. This was causing an immediate issue on a project, so I went with the band-aid approach.
@ahorner what version of Rails are you on?
4.2.0
@ahorner I'm having a hard time reproducing. Specifically, app.routes.recognize_path(mount_at)
always throws an exception for me, so there is never a check against the :action
.
Maybe you can fill in some details. What is special about your usage of Teaspoon or your app's configuration or routes? Can you paste applicable code from your app here?
Related: #191
For my current project, we have a catch-all route defined at the end of the routes file like so:
routes.rb
get "*unmatched_route", unmatched_route: /(?!.*rails\/mailers).*/, to: "errors#not_found"
In this case, recognize_path
returns an action of not_found
(the action for the catch-all route), and teaspoon just silently loads without attempting to prepend its routes. We've managed to avoid the issue for the time being by just adding teaspoon
to our unmatched route regex, but it's sort of a weird interaction.
The approach in this PR is probably overkill, but we should at least touch up the documentation.
So, I have a test app that is running Rails 4.2.1 and Teaspoon 0.9.1. I have this as the last route in my routes.rb
:
get '*path', to: "errors#not_found"
When I debug into the suspect line, app.routes.recognize_path(mount_at)
, it always throws an exception.
What could be differing? Are you able to reproduce this in an entirely new app?
I'm not having any luck recreating the issue in an isolated test case, so the issue must be a weird interaction with something else in our stack. I poked around for a while without any success; I'll update this again once I figure out exactly where the problem is coming from. In the meantime, sorry for the wild goose chase.
No problem. I appreciate your time trying to track this down!
Hey @ahorner, I'm going to close this issue for now. Happy to reopen if you find anything on your end.
We currently prepend Teaspoon’s routes in an effort to prevent catch-all routes from intercepting traffic intended for the Teaspoon engine.
However, recent changes have hard-coded “routing_error” as the only viable catch-all action, meaning that any custom catch-all routing will prevent Teaspoon’s routes from being prepended. The solution I’ve opted for here is to allow users to specify their custom catch-all action, so that Teaspoon can still properly mount when a path is undefined.