View inheritance and rendering in engines

11 views
Skip to first unread message

Linus Pettersson

unread,
Oct 11, 2013, 9:01:03 AM10/11/13
to rubyonra...@googlegroups.com
Hi

I'm creating a mountable admin engine (like Active Admin but not as advanced) using Inherited Resources. Let's call it AdminFoo.
In my main app I mount it with mount AdminFoo::Engine, at: '/admin' in my routes file.

Let's say I have the following structure in my engine:

AdminFoo
app
- views
- - admin_foo
- - - resource
- - - - index.html.erb
- - - shared
- - - - _nav_bar.html.erb

If I want to render _nav_bar in my index.html.erb file I need to reference it from the view root, like this: render 'admin_foo/shared/nav_bar' 
Now I want to override the nav_bar partial from my main app like this:

MainApp
app
- views
- - admin
- - - shared
- - - - _nav_bar.html.erb


However, this doesn't work since it looks for the file in 'admin_foo/shared/nav_bar'
I don't want to create an admin_foo folder in my main app since I already have the admin folder which the engine mounted under. This works for controllers, for instance I have this structure for my custom admin controllers and its views:

MainApp
app
- controllers
- - admin
- - - Admin::BarController < AdminFoo::ResourceController
- views
- - admin
- - - bar
- - - - index.html.erb

It is weird to have both admin AND admin_foo folders in my main app.
Reply all
Reply to author
Forward
0 new messages