简体   繁体   中英

Engine's routes not available in host's views

I got an application that I turned into an engine which has tons of routes. I added the engine to a host app via Gemfile and when I run rake routes everything is displayed properly. However, in the views, the routes aren't found resulting in this error:

I access / and get following error:

No route matches {:controller=>"reports" :action=>"new"}

in file /Users/username/Sites/engine_app/app/views/home/index.html.erb :

<%= link_to 'New Report', new_report_path %>

rake routes:

...
reports#new                      new_report GET    /:locale/reports/new(.:format)
...

Also, I can access /en/reports/new which loads the correct controller and view but get another routing error.

To me, it seems I can access any route directly but the app cannot resolve any xxx_path inside the views at all. Any suggestions?

Considering the lack of details in question, I can think only that you are trying to access it from a wrong url. /:locale/reports/new(.:format)

you probably open the url without locale:

localhos:3000/reports/new

but it should be:

localhos:3000/en/reports/new

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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