Thanks for the reply.    I did end up doing something like this:

Topic.search("steve",
                     :conditions => {:discussable_type => "Band"},
                     :with => { :discussable_id => 1 })

A nice feature might be to allow

has :discussable, :polymorphic => true

So you could then do

Topic.search("steve", :condtitions => { :discussable =>
@discussable })

and have it work this out on its own.







On Feb 18, 3:11 am, Pat Allan <[email protected]> wrote:
> Hi Stephen
>
> Conditions can (and should) be strings - because they reference fields. 
> Filters (managed by the :with option, as you've used already), must be 
> integers, timestamps, booleans or floats.
>
> So, filtering on discussable_id is easy enough, because it's an integer, and 
> you can use it in a filter. You can combine this with a search upon a field 
> for discussable_type, although field searches make use of Sphinx's smarts - 
> which is good in some situations, but can get in the way in others...
>
> So, you may want to add a CRC'd attribute for discussable_type 
> instead:http://freelancing-god.github.com/ts/en/common_issues.html#string_fil...
>
> Does this fit what you're after?
>
> --
> Pat
>
> On 18/02/2010, at 5:58 AM, Stephen wrote:
>
> > I've created a message board system thats completely polymorphic, it
> > can be attached to pretty much any other object in my program and it
> > just works.
>
> > So I want to be able to search for all topics, within a particular
> > board.  When it was tied to just a band_id  this was easy as
>
> > has band_id
>
> > :with =>  { :band_id => 5 }
>
> > Now, topics have a discussable_id and a discussable_type.   It seems
> > that conditions/attributes must be an integer of some kind - so how
> > can I filter based on that relationship?
>
> > Thanks..
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Thinking Sphinx" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to 
> > [email protected].
> > For more options, visit this group 
> > athttp://groups.google.com/group/thinking-sphinx?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.

Reply via email to