# Comparing created at

**URL:** <https://www.ruby-forum.com/t/comparing-created-at/150006>\
**Category:** Rails\
**Created:** [October 2, 2008, 10:28am UTC](https://www.ruby-forum.com/t/comparing-created-at/150006 "2008-10-02T10:28:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [October 2, 2008, 10:28am UTC](https://www.ruby-forum.com/t/comparing-created-at/150006/1 "2008-10-02T10:28:32Z")

</div>

I set up a simple blog in my rails app and on the forum index page  
would like to display when the most recent activity was.

I have two table in my database, one for posts and the other for  
replies.

My question is, how can I compare the created\_at tags for two  
different models?

I need some sort of conditional statement like

\<% if forum.topic.last.created\_at \< forum.replies.last.created\_at %\>

and then display the most recent activity.

Any ideas much appreciated,

Dan

---

<div class="post-metadata">

**Author:** ![DanC](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@DanC](https://www.ruby-forum.com/u/DanC)\
**Post date:** [October 2, 2008, 11:20am UTC](https://www.ruby-forum.com/t/comparing-created-at/150006/2 "2008-10-02T11:20:04Z")

</div>

On 2 Oct 2008, at 01:05, DanC wrote:

> I need some sort of conditional statement like
> 
> \<% if forum.topic.last.created\_at \< forum.replies.last.created\_at %\>

Something like that is fine. What’s stopping you from going ahead and  
doing that ?

Fred
