Sometimes you want to add some related information to a model. It is for example a good idea to add authors name to the Ferret document which indexes a book.
To achieve this, you only have to declare a new method in your model which return the data you want to index. Then you need to add this method to the acts_as_ferret field arguments. Let’s see an exemple :
Class Book < ActiveRecord::Base
acts_as_taggable :authors
acts_as_ferret :field=>[:title, :description, :authors_for_ferret]
def authors_for_ferret
author_names.join(' ')
end
end
Class Author < ActiveRecord::Base
end
Now you can make full text search on your library with author included.
Comments