Q:

Different partials for different type of content

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'? 

A:

I'd create a helper which inflects the partial from the content_type, something like:
def render_post(post)
  template = post.content_type.sub(/Story$/, '').downcase
  render :partial => "posts/#{template}", :locals => { :content => post }
end

