Tumblelog by Soup.io
Newer posts are loading.
You are at the newest post.
Click here to check if anything new just came in.

March 26 2010

16:29

the { buckblogs :here }: Helping ActiveRecord finders help you

class Thing < ActiveRecord::Base def self.find(*args) if args.first.to_s == "random" ids = connection.select_all("SELECT id FROM things") super(ids[rand(ids.length)]["id"].to_i) else super end end end