Hi there, I have a similar problem. I'm building a CMS and we have a 
tree model called component_instances. This model has polymorphic 
associations with many other models (e.g. Links, Folders, Pages etc...) 
I want the user to be able to search for an instance using data stored 
in the associated models. To start with in the backend interface, I only 
want them to be able to search for items by name, so I came up with 
this:

class ComponentInstance < ActiveRecord::Base
  has_many :permissions
  has_many :groups, :through => :permissions
  belongs_to :component #will be in different database ??
  acts_as_tree :order => 'position'
  acts_as_list :scope => 'parent_id'
  belongs_to :instance, :polymorphic => true
  acts_as_ferret(
    :fields => :instance_name
  )

  def instance_name
    instance.name
  end

end

Now that looks like it should work. But when I search for an item by 
name (knowing that it exists), nothing shows. I know the search itself 
works because becure I added the :fields condition, it would pick up and 
return results for the word "folder" as it was used to define the 
polymorphic associations on the instances table.

So firstly your help with that problem would be most appreciated. Then 
we make things trickier by adding the fact that I'd like the end users 
on the front end to be able to search the site not just using the name 
field, but basically anything in any of the instance tables.

As a laughing point, when I wrote the original application in PHP using 
Mysql fulltext search, the query for the frontend search was 2 pages 
long! :)

Looking forward to your great ideas! :)

-- 
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ferret-talk mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ferret-talk

Reply via email to