# Recommendation for searching with regards to timestamp & foreign key 	attributes

**URL:** <https://discuss.rubyonrails.org/t/recommendation-for-searching-with-regards-to-timestamp-foreign-key-attributes/50713>\
**Category:** rubyonrails-talk\
**Created:** [April 7, 2010, 12:58pm UTC](https://discuss.rubyonrails.org/t/recommendation-for-searching-with-regards-to-timestamp-foreign-key-attributes/50713 "2010-04-07T12:58:36Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gordon\_Yeong](https://avatars.discourse-cdn.com/v4/letter/g/e47c2d/32.png) [@Gordon\_Yeong](https://discuss.rubyonrails.org/u/Gordon_Yeong)\
**Post date:** [April 7, 2010, 12:58pm UTC](https://discuss.rubyonrails.org/t/recommendation-for-searching-with-regards-to-timestamp-foreign-key-attributes/50713/1 "2010-04-07T12:58:36Z")

</div>

hi guys,

&nbsp;&nbsp;&nbsp;I need a recommendation for searching with regards to timestamp & foreign key attributes. Sounds a bit too much but here's an example.

&nbsp;&nbsp;Suppose we have a "blog" object. It has many attributes such as - title - content - status\_id - created\_at - updated\_at

&nbsp;&nbsp;There are also "status" objects which have the following statuses, "new", "edit","published","archived". That's why the "blog" object has a foreign key, "status\_id".

Now, suppose I want to search for all blog objects that have been created in the past 24 hours. I would do

&nbsp;&nbsp;new\_blogs = Blog.all(:conditions =\> { :created\_at =\> (Time.now - 24.hours) .. (Time.now) } )

Tested and that works just fine.

Suppose I would like to get all blog entries which are not of the status of 'published' or 'archived'. I would just make use of searchlogic in the following way:

new\_blog\_entries = Blog.searchlogic(:status\_name\_does\_not\_equal\_all =\> (['published', 'archived']) ) OR new\_blog\_entries = Blog.status\_name\_does\_not\_equal\_any(['published', 'archived'])

Question:
