60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
# File 'lib/tagalong/tagger.rb', line 60
def tags_including(options={})
out = []
query = self.tagalong_tags.order("name ASC")
if options[:has_been_tagged]
query = query.
select("tagalong_tags.id, tagalong_tags.name, tagalong_tags.number_of_references, tagalong_taggings.id as used").
joins("LEFT OUTER JOIN tagalong_taggings ON tagalong_taggings.tagalong_tag_id = tagalong_tags.id AND tagalong_taggings.taggable_id = '#{options[:has_been_tagged].id.to_s}'")
end
query.each do |tag|
hash = {:name => tag.name}
if options[:number_of_references]
hash[:number_of_references] = tag.number_of_references
end
if options[:has_been_tagged]
hash[:has_been_tagged] = !tag.used.nil?
end
out << hash
end
return out
end
|