Created
September 18, 2010 10:33
-
-
Save bjeanes/585553 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
# This is until there is a nested_has_many_through solution for Rails 3 | |
# to let us do something like: | |
# | |
# has_many :interests, :through => :users, :select => "DISTINCT tags.*", | |
# :class_name => "ActsAsTaggableOn::Tag" | |
def interests | |
ActsAsTaggableOn::Tag. | |
select("DISTINCT tags.*").joins(:taggings). | |
where("taggings.context" => "interests"). | |
where("taggings.taggable_type" => "User"). | |
where("taggings.taggable_id" => user_ids). | |
order("tags.name") | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment