class Item < ActiveRecord::Base
has_and_belongs_to_many :groups
define_index do
indexes title
indexes body
has groups(:id), :as => :groups
end
Item.search(searchstring, :page => page,:conditions => {:groups => group)
# I pass a group id into the search
end
ActionView::Template::Error (index item_core: query error: no field 'groups' found in schema):
Nice to know things have mostly been working well. Here's a few tips for what you're trying to do.
First up - you've defined groups as an attribute, which makes sense - though I would probably call it group_ids, given it is a collection of ids. Next, to filter on attributes, you need to use :with, not :conditions (that's for fields only). You also need to pass through the actual id value, not a model.
So, with your first setup, the query should be as follows:
Item.search searchstring, :page => page, :with => {:groups => group.id}
When it comes to testing, it depends how you want to do this… I recommend stubbing out calls in controller/model tests, and then with Cucumber and/or Capybara acceptance tests, have a look at ThinkingSphinx::Test and this blog post:
http://freelancing-god.github.com/ts/en/testing.html#functional
http://freelancing-gods.com/posts/using_thinking_sphinx_with_cucumber
If there's any more questions, just let me know.
Cheers
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/xStJo722WZAJ.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
--
Pat
> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To view this discussion on the web visit https://groups.google.com/d/msg/thinking-sphinx/-/bAsEn-VZOA0J.