I'm looking for how others typically organize their partials for a polymorphic resource.
Example:
I have Image
which is polymorphic and depending on what is imageable
, I want to display things slightly different.
I have a partial images/_image
and can call render imageable.images
. My current mindset is to have my image partial check what type imageable
is and then have another partial, specific to that case. My organization would be something along the lines of:
images/
_image.html.haml
_product.html.haml
_post.html.haml
_user.html.haml
My _image
partial would look something like:
%div
= render :partial => "images/#{imageable.type}"
Does this seem like a bad approach, or flat out the wrong approach? My thinking is that keeping the ability to just call render imageable.images
from elsewhere is much nicer than having to call render :partial => ...
all over the place.
Any ideas would be greatly appreciated.