I have a rails 3 app where I am using acts_as_taggable_on to tag a Post model. I have a search box which allows me to search through the posts, where I use acts_as_indexed. In my search, I want to also be able to search through all the tags, by extending the ActsAsTaggableOn::Tag class to support acts_as_indexed. How do I do that?
I tried the following:
# lib/tag.rb
module ActsAsTaggableOn
class Tag
acts_as_indexed :fields => [:name]
end
end
but then I get the following error when I try to call find_with_index:
> ActsAsTaggableOn::Tag.find_with_index('foo')
undefined method `find_with_index' for ActsAsTaggableOn::Tag(id: integer, name: string):Class
UPDATE: I made this work using acts_as_taggable_on's built in finders (specifically, Tag#named_like), but I would prefer to use acts_as_indexed, since I use it with all the other models in my app, and I am having to special case tag searching due to this issue.
Thanks,