I have Rails application with mounted Engine.
#{main_app}/config/routes.rb
mount CommentIt::Engine => "/talk", :as => 'comment_it'
And want to open engine views within main application layout.
#{main_app}/app/views/layouts/application.html.erb
<html>
<body>
<%= link_to "users", users_path %>
<%= yield %>
</body>
</html>
When accessing engine views(0.0.0.0:3000/talk) I got error ‘undefined method `users_path’ for #<#:0x007f9dbf0f7800>’
users_path works fine in main application views.
How I get route helpers from main application, when accessing Engine pages?
As of Rails 3.2 the only way to do this is convert your engine into a ‘full’ engine and not a mountable engine. In mountable engines, the engine has no knowledge of the host application and its path/url helpers are not accessible by default.
This answer explains what needs to be done, which worked for me.
The alternative is to traverse the host application’s files and include the proper view/application helpers into your engine. It works, but for me it was too much of a hassle. Simply converting to a full engine did the trick.