I've been using as suggested:
index.wants.html do
render :action => "#{parent_type.to_s.underscore}/index"
end
It's not perfect, since the template is under polymorphic_controller/
parent_controller instead of parent_controller/polymorphic_controller
which I'd prefer. It does allow custom templates for polymorphic
controllers, though.
The alternative is logic in the view template itself, which I'd like
to avoid for this sort of thing.
So, it ends up being
comment/request/index.html.erb
comment/option/index.html.erb
comment/_index.html.erb
request/_menu.html.erb
For the common stuff, I include a partial and another with menu
options.
render :partial => 'comment/index'
render :partial => 'request/menu'
And that can easily be a helper that uses parent_type to determine the
right template path for the sub-menu header I have.
r_c makes it pretty easy. I am essentially pleased with the result.
I was messing with namespaces and stuff to try to achieve nesting a
non-polymorphic controller with no view switch logic at all as say,
Request::Comment, but it was far more pain than it seemed to be worth.
(I discovered that CommentController and Request::CommentController
may collide or some such, but I am uncertain the resolution.)
http://www.ruby-forum.com/topic/125392
Instead, if Request needs another instance variable for, say, the
index action, while Project does not, I ended up with
index.before do
case parent_type
when Request then
@request = parent_object
end
end
which I'd need to do anyway with a r_c controller that wasn't
polymorphic.
Thanks!
> usenamespaceto separate functionality. I don't really want /