I'm writing a plugin for a Rails application (Discourse) and setup routes like this:
Discourse::Application.routes.append do
root to: 'custom#show'
end
Unfortunately, the Rails application already defines a series of root routes in its routes.rb
file. Since they're specified first, they take precedence according to “Rails Routing from the Outside In: 2.2 CRUD, Verbs, and Actions” .
However, I noticed an odd logger entry when changing the route setup like this:
Discourse::Application.routes.prepend do
root to: 'custom#show'
end
By using prepend
instead of append
, Rails' logger output now claims this when requesting the root path /
:
INFO -- : Started GET "/" …
INFO -- : Processing by CustomController#show as HTML
However, the action CustomController#show
is not actually called. The application behaves exactly as before. How can I get Rails to call this controller and action instead just like the logger claims?
(This is kind of a follow-up question to “For routes with identical URI patterns, which is matched first?” )
Probably some kind of infinite look in your before_action
s / ApplicationController
/ or the inherited Discourse controller.
You can debug it with logging statements and Ctrl-C
during the request to see where is the hang (the stacktrace will appear).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.