设置
引擎的routes.rb
MyEngine::Engine.routes.draw do
get '/:guid', :to => 'foo_bar#index'
end通过mount MyEngine::Engine, :at => '/some_route'装载在主机应用程序中
问题
在主机应用程序的帮助器中的某个位置:
generated_link = my_engine.root_path(some_guid_i_got)结果:
undefined method `root_path' for #<ActionDispatch::Routing::RoutesProxy:0x00007ff443d405a0>我尝试添加include MyEngine::Engine.routes.url_helpers,但这破坏了一堆甚至与引擎无关的其他路由。除了这个url-helper之外,引擎正在工作,但我不想在中硬编码url。
为/some_route/a-guid-here生成url的正确方法是什么?
提前感谢
发布于 2019-02-22 10:58:56
错误是让您知道哪里出了问题。undefined method root_path告诉您它找不到已定义的root_path,这是您的路由文件中必须具有的路径。
https://stackoverflow.com/questions/54819056
复制相似问题