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

widget inside engine with namespace, problem using url_for_event #122

Open
astenuz opened this issue Sep 23, 2013 · 2 comments
Open

widget inside engine with namespace, problem using url_for_event #122

astenuz opened this issue Sep 23, 2013 · 2 comments

Comments

@astenuz
Copy link

astenuz commented Sep 23, 2013

Hi, i'm trying to use apotomo from a mountable engine (with namespace in modules and routes) but i'm having some problems doing it. The apotomo gem is mounted on the main project and i'm using it from the engine. When i try to use the helper url_for_event from outside a widget inside the engine, it crashes. It raises the next error:

undefined method `apotomo_event_path' for #<GrooveVideoChat::SessionsController:0xbbd65360>

Here GrooveVideoChat is the engine, inside it has the controller for sessions , sessions controller inside has:

has_widgets do |root|
      root << widget('groove_video_chat/video_chat')
end

And the view for the action new session calls url for event, here is the code:

=url_for_event(:submit, :source => "groove_video_chat/sessions")

url_for _event works inside the widget itself, however i have to make certain tweak. Remove the namespacing in the route.

url_for_event(:submit).sub("/video_chat","")

/video_chat appears because the engine is mounted in the main app as follows.

mount GrooveVideoChat::Engine => "/video_chat"

Thanks in advance

@AlexVangelov
Copy link

Same issue (apotomo_event_path inside isolated engine)
About main_app route: match ":controller/render_event_response" ... :as => "apotomo_event"
Inside engine, apotomo_event_path builds "engine_mount_point/engine_namespace/controller_name..etc"
We have namespaced controller.
I tried to put the same route to Engine.routes and add 'use_route' param, but it's not possible because ":controller segment is not allowed within a namespace block"
Rails route knows the namespace of controller after the engine mount pont, so it must work if engine's namespace is omitted from Widget.controller_path.. hmm I'll try

@AlexVangelov
Copy link

A working fix is to override apotomo_event_path for widget inside engine
def apotomo_event_path(options = {})
Rails.application.class.routes.url_helpers.apotomo_event_path(options)
end
but there must be a better solution

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

No branches or pull requests

2 participants