June 08, 2006

Posted by John

Older: Want railstips.org?

Newer: Acts As Versioned With Associations

Updates To Active Record Find

According to changeset 4425 find just got a bit of an update. You can now pass in a hash to the condition parameter and it will be converted to an AND-based condition string.

The following …

Person.find(:all, :conditions => [ "last_name = ? and status = ?", "Catlin", 1 ], :limit => 2)

is now the same as …

Person.find(:all, :conditions => { :last_name => "Catlin", :status => 1 }, :limit => 2)

0 Comments

Thoughts? Do Tell...


textile enabled, preview above, please be nice
use <pre><code class="ruby"></code></pre> for code blocks

About

Authored by John Nunemaker (Noo-neh-maker), a programmer who has fallen deeply in love with Ruby. Learn More.

Projects

Flipper
Release your software more often with fewer problems.
Flip your features.