Skip to content

Instantly share code, notes, and snippets.

@rubysolo
Created May 26, 2010 15:54
Show Gist options
  • Select an option

  • Save rubysolo/414669 to your computer and use it in GitHub Desktop.

Select an option

Save rubysolo/414669 to your computer and use it in GitHub Desktop.
def self.resolve(brandish)
case brandish
when Brand
brandish
when Fixnum
find(brandish)
end
end
named_scope :by_brand, lambda { |brands|
brand_list = [*brands].map{|b| Brand.resolve(b) }
{
:include => [:brand, :classification],
:conditions => ["brand_id IN (?)", brand_list.map(&:id)],
:order => 'classifications.name'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment