[英]RAILS: Access other path helpers after routing into mounted class
Say I'm integrating forem
into my apps, and my routes.rb
seems like this: 假设我正在将forem
集成到我的应用中,而我的routes.rb
看起来像这样:
# items
resources :items, only: [:index, :show]
# forem
mount Forem::Engine, :at => '/forums'
And In my default layout layout/Application.erb.html
, there's something like: 在我的默认布局layout/Application.erb.html
,类似:
link_to 'items', items_path
and, in /forums
pages, it occurs that: 并且在/forums
页面中,发生以下情况:
undefined local variable or method `items_path'
so, how can I access other path helpers after routing into mounted class 因此,路由到已安装的类后如何访问其他路径助手
您必须像这样在路径前面添加main_app:
link_to 'items', main_app.items_path
never mind guys, pls check this: 没关系,请检查以下内容:
https://github.com/radar/forem/wiki/Installing---Upgrading#application-route-helpers https://github.com/radar/forem/wiki/Installing---Upgrading#application-route-helpers
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.