Reputation: 768
On my Rails 5.0.7 application I have Thredded (0.15.4) mounted as an engine in a namespace.
#routes.rb
namespace :home do
mount Thredded::Engine => "/communities", as: "thredded"
end
This allows me to access /home/communities to pull up the thredded interface.
Unfortunately, this also leads to unexpected behavior. The rails route proxy is not thredded
as expected, but rather home_thredded
. If I wanted to access a named route inside my engine, I need to do home_thredded.root_path
instead of thredded.root_path
This is especially troublesome because thredded.root_path
is actually referenced in the code of the thredded gem itself, which now throws an error.
Is there some way to explicitly set the routing proxy to avoid needing to include the namespace in the routing proxy?
A few things that I've considered and rejected:
I could directly edit the code in the offending file of the gem, but that would be annoying to maintain.
I could also write a decorator that overwrites the offending method so that it uses the correct rails routing proxy, but that would still mean that I would have to use the home_thredded.some_path
anywhere rather than the expected thredded.some_path
I could not namespace the engine. This could work, but it would break the naming conventions of the rest of the application.
Upvotes: 0
Views: 388
Reputation: 20263
Have you tried:
scope :home do
mount Thredded::Engine => "/communities", as: "thredded"
end
That should add /home
to your URI Pattern but leave your Controller#Action
and Prefix
s unchanged.
Upvotes: 2