How to recongnise routes in a Rails App

寵の児 提交于 2020-01-04 05:04:21

问题


I have this very basic question. I am using this dashboard rails engine, and this gives me a views/layouts/dashing/dashboard.html.erb. This is the layout of the dashboard view.

But I want to customize this view, like add a navigation bar, that has a link which point to my about_path. However, none of the routes are recognized in the dashboard view. It results in an error undefined method about_path.

But the about_path route is defined in my routes file and is working fine in other views that dont belong to dashboard.

Is there any way a rails engine recognizes routes defined in my application?


回答1:


If you wish to reference the application inside the engine in a similar way, use the main_app helper:

<%= link_to "About", main_app.about_path %>

here is link for reference rails routes guide



来源:https://stackoverflow.com/questions/46054401/how-to-recongnise-routes-in-a-rails-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!