简体   繁体   English

RAILS:路由到已安装的类后,访问其他路径助手

[英]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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM