I'm not sure if this is what you're asking but this is what i've implemented in a partial called _newest_date.rhtml :
<% if newest_date.created_at == newest_date.updated_at %> <%= newest_date.created_at.strftime("Created on %m/%d/%Y") %> <%= newest_date.created_at.strftime("at %I:%M%p") %> <% else %> <%= newest_date.updated_at.strftime("Updated on %m/%d/%Y") %> <%= newest_date.updated_at.strftime("at %I:%M%p") %> <% end %>
And i call this for every post that is shown in a page. With a little more detail the list.rhtml file :
<% for post in @posts %> <div class="post" id="post_<%= post.id %>"> <h3><%= link_to h(post.title), :action => 'edit', :id => post %></ h3>
<ul class="post_info"> <%= render :partial => 'newest_date', :object => post %> </ul>
[.... stuff here.....]
</div> <% end %>
You could call a partial like this one from inside another partial.
I'm pretty sure this is NOT the best way to do it, but i'm pretty new at rails so this is a *fast* solution i found for my problem, which in this case is to either print the created_at date or the updated_at date according to which one is the newest.
P.S.: The controller just returns the @posts collection through a paginator :
def list @post_pages, @posts = paginate :posts, :order => 'id DESC', :per_page => 10 end
--Hope i helped a little