class User < ActiveRecord::Base
has_many :assets, :foreign_key => 'creator_id'
def avatar_asset size = :thumb
self.assets.find :first, :conditions => ["thumbnail = '#{size}' and filename LIKE ?", self.login + "_#{size}.%"]
end
end
Refactorings
No refactoring yet !
How do I turn this into a has_one association? (Possibly has_one + a named scope for size.)