Are there any plugins/mixins that provide an OO partial view
framework?
e.g
If A < B (subclass) and A < C,
As I’m rendering a list of A’s, depending on the type of A, attempts
to render _B_as_listitem or _C_as_listitem first, otherwise render’s
_A_as_listitem (super), each partial would take the an object of type
A as a param.
This would be a bad implementation of the idea:
models
class A < ActiveRecord::Base
class B < A
class C < A
AController
def list
@list_of_a = A.find(:all)
end
list.html.erb
<% for a in @list_of_a %>
<% render :partial => ‘A_as_list_item’, :locals => {:object => a} %>
<%end%>
_A_as_list_item
case a[:type]
when ‘B’
<% render :partial => ‘B_as_list_item’, :locals => {:object => a}
%>
when ‘C’
<% render :partial => ‘C_as_list_item’, :locals => {:object => a}
%>
end