I seem to be getting some behaviour thats unexpected (for me anyway)
when using find_by_contents on an ActiveRecord has_many association. The
results that are returned are only the records that belong to the model
returned, but the total_hits that are being returned appear to be for
the whole table.
e.g.
class Book < AR::Base
has_many :pages
end
class Page < AR::Base
belongs_to :book
acts_as_ferret :fields => [:content]
end
b1 = Book.create(:title => "Book One")
b1.page.add(:content => "The cat sat on the mat.")
b1.page.add(:content => "The cat went for a walk in the country.")
b2 = Book.create(:title => "Book Two")
b2.page.add(:content => "Once upon a time in a country quite far away.")
b2.page.add(:content => "There lived a man with his cat.")
results = b1.pages.find_by_content("cat)
results.total_hits #=> 3
results.results.length #=> 2
b1.pages.total_hits #=> 3
Is this the expected behviour? Is there any way to get total_hits to
report the total_hits only for the pages belonging to b1?
It will make pagination very difficult otherwise.
Cheers,
Steve
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk