Created
May 26, 2010 15:54
-
-
Save rubysolo/414669 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def self.resolve(brandish) | |
| case brandish | |
| when Brand | |
| brandish | |
| when Fixnum | |
| find(brandish) | |
| end | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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