ActiveRecord::Extensions 0.5.0 Released! 14 Mar 2007
ActiveRecord::Extensions 0.5.0 is released! This release includes support for querying against Time objects against ActiveRecord columns which are considered :datetime by ActiveRecord’s standards (this typically include DATETIME and DATE database columns).

Code Example

To find all blog posts within the last week:

BlogPost.find( :all, :conditions=>{ :created_at_gt => } )

To find all posts within the last year:

BlogPost.find( :all, :conditions=>{ :created_at_gt => } )

To find all posts over a year old:

BlogPost.find( :all, :conditions=>{ :created_at_lt =>} )

To find all users who logged in within the past 15 minutes:

User.find( :all, :conditions=>{ :logged_in_at_gt =>} )

Supported Suffix Modifiers

This particular query addition supports the following column name suffix modifiers (ie: the “_lt” in the “created_at_lt”).

  • _lt => less than
  • _gt => greater than
  • _lte => less than or equal to
  • _gte => greater than or equal to
  • _ne => not equal to
  • _not => not equal to
  • _eq => equal to (this is implied without a suffix present)


This does not work on TIMESTAMP columns for MySQL due to an issue with the inconsistency of TIMESTAMP columns in varying versions of MySQL and due to the nature of server configurations which can alter the behavior of TIMESTAMP columns.

PostgreSQL Support Note

I recently switched to a Mac, I am compiling PostgreSQL 8.1 and 8.2 as I type this. As soon as I can test this functionality against PostgreSQL I will release an update with that support.

Download It Now!

  • Rubyforge: “”:

blog comments powered by Disqus