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
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---
On Tue, Oct 30, 2007 at 05:18:29PM -0000, steve13o wrote:> 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%>[...] <% @list_of_a do |a| -%> <%= render :partial => "#{a.class}_as_list_item", :object => a %> <% end -%> --Greg --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---