Gents,
I’m using the acts_as_taggable rails plugin (not gem), and would like to
add some additional methods to it. For example, the find_tagged_with
methods essentially does a find tag in a list (effectively an OR), while
I’d like to implement a find_tagged_with_all method that would implement
an AND (so if I specified 4 tags, it would only return items that were
tagged with all four inclusively).
Is there a proper way to extend a Rails plugin so that problems are
minimized downstream when the plugin is upgraded? Or should I just dive
right in the plugin code and hack away?
FYR, I want to add a method to the following module:
module SingletonMethods
def find_tagged_with(list)
find_by_sql([
"SELECT #{table_name}.* FROM #{table_name}, tags, taggings "
+
"WHERE #{table_name}.#{primary_key} = taggings.taggable_id "
+
"AND taggings.taggable_type = ? " +
“AND taggings.tag_id = tags.id AND tags.name IN (?)”,
acts_as_taggable_options[:taggable_type], list
])
end
end
Thanks!
B.A.
B.A. Baracus: I thought you weren’t crazy no more?
Murdock: Only on paper.