Searching within active record results - ror n00b


I am trying to set up a search page that looks within a product catalog.

There are several many to many relationships with the items object.

I am trying to be able to narrow searchs and then allow for text
using tsearch2 and postgres.

@format = Format.find(@params[:format_id])
@items = @format.items

And then do a find_by_sql on the @items, but I know this isnt how you do
@items.find_by_sql("SELECT * FROM items WHERE idxfti @@
to_tsquery(‘default’, ‘#{@str}’)

class Format < ActiveRecord::Base

has_and_belongs_to_many :items

belongs_to     :parent,
            :class_name => "Category",
            :foreign_key => "parent_id"

has_many    :children,
            :class_name => "Category",
            :foreign_key => "parent_id",
            :order => "title",
            :dependent => true

validates_presence_of :title


class Item < ActiveRecord::Base

has_and_belongs_to_many :formats
has_and_belongs_to_many    :keywords
has_and_belongs_to_many    :images

has_many                :reviews


Thanks for any pointers