Scoping acts_as_ferret

I have acts_as_ferret up and running but I need to scope it so that it only returns records from a table with a certain foreig key. Anyone have a good resource for this?

Have you indexed the foreign key field? If so just add a FieldQuery to the end of your query.

For example if your foreign key field is “book_id” and you only want records with a “book_id” of 3 you’d add “book_id:3” to the end of your query. Or perhaps you want a range of “book_ids”, you should be able to do “book_id:[3 9]” to find all records with a foreign key field of “book_id” between 3 and 9.

Good resources are the following sites:

You can also check out the ferret mailing list:

There’s also some other sites that give examples of using acts_as_ferret. You just need to google for “acts_as_ferret” to find a lot of them.

I use the above example in my own project, but it’s not a foreign key field; instead, I’m using a table with STI and I scope the results based on the inheritance column.

Hope that helps,