I need some help getting a rails engine to communicate with my host application.
I've got a standard layout file in the engine.
app/views/layouts/my_engine/application.html.erb
and my host app has the standard
app/views/layouts/application.html.erb
In the host app, I've gota partial that contains a nav bar. I would like to use this nav bar in pages that are generated by the engine.
I have no idea how to do this.
My first attempt at solving this was to create another version of this file in my host app, thereby overwriting the original behavior.
app/views/layouts/my_engine/application.html.erb
I was hoping this strategy would work, but the nav bar partial now has no knowledge of the routes that belong to the host app. It throws a 'no method' error on any named route in the host app.
So how do I allow the engine to render views in the host app, but ultimately rely on the host app's structure for pages as defined in app/views/layouts/application.html.erb
?
Copying this from the comments, so that other people don't miss it:
I found this post, which answers my question: Render engine within application layout
credit to OP for finding the solution
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With