In Post model I’ve got an attribute like “content_type”. Posts of different types should be displayed in different way on the same list. For now I’ve got only one idea to do this:
<%=
@posts.each do |d|
if d.content_type == "NormalStory"
render :partial => 'posts/normal', :locals => { :content => d }
elsif d.content_type == "FotoStory"
render :partial => 'posts/foto', :locals => { :content => d}
elsif d.content_type "VideoStory"
render :partial => 'posts/video', :locals => { :content => d }
end
end
%>
Could you please recommend me something more ‘elegant’?
I’d create a helper which inflects the partial from the
content_type, something like: