How to recongnise routes in a Rails App

2019-07-05 05:24发布

问题:

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