Created
November 22, 2013 20:56
-
-
Save Breefield/7606749 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
# Type is a :symbol of the model which you want to filter by | |
def self.filtered_by type | |
belongs_to type, :foreign_key => :located_id, :foreign_type => type.to_s.capitalize | |
where(:located_type => type.to_s.capitalize).joins(type).includes(:located) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment