Created
November 26, 2010 10:00
-
-
Save laurynas/716490 to your computer and use it in GitHub Desktop.
SearchLogic problem with left join in order SOLVED!
This file contains 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
class Item < ActiveRecord::Base | |
named_scope :ascend_by_optional_category_title, | |
:joins => "LEFT JOIN categories AS optional_categories ON optional_categories.id=items.category_id", | |
:order => "optional_categories.title" | |
named_scope :descend_by_optional_category_title, | |
:joins => "LEFT JOIN categories AS optional_categories ON optional_categories.id=items.category_id", | |
:order => "optional_categories.title DESC" | |
end |
This file contains 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
Item.search( :order => :ascend_by_optional_category_title ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment