Hello,
I''m building a little polymorphic page (I mean that you use the same
page to deal with objects coming from different models, for instance
users and products) and I need to render some partial templates if they
exist, and get no error if they don''t (for instance I''ve got a
partial
template called _optional_fields_user which I''d like to load, but
_optional_fields_product doesn''t exist and I''d like to use the
same code
to load both.
So I build a little helper :
def render_if_exists toRender
begin
render toRender
rescue ActionView::ActionViewError
end
end
and I call it :
<%=render_if_exists :partial
=>"optional_fields_#{@element.className}"%>
Everything works fine but I think it''s ugly to do it this way, would
anyone have anything better?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---