I wrote the following rails code in one of my models:
su = self.find(:first,
["scrape_type = ? and finished = 0", scrapetype],
:order=>"updated_at");
According to development.log, this generated the following SQL:
SELECT * FROM scrape_urls ORDER BY updated_at LIMIT 1
Note that the man page
http://rubyonrails.org/api/classes/ActiveRecord/Base.html contains an
example with the above format:
Company.find(:first, [
"id = :id AND name = :name AND division = :division AND created_at
:accounting_date",
{ :id => 3, :name => “37signals”, :division => “First”,
:accounting_date => ‘2005-01-01’ }
])
Bug #1: Since rails ignored the array that I supplied, Rails should
have generated an error.
Bug #2: The documentation is probably incorrect. I currently suspect
that the phrase “:condition=>” should appear before the open bracket.
Bug #3: It’s too hard to figure out how to submit a bug report to
rails. Hope you guys find this and fix your code.