Store_class_name for Comatose:Page model

Hi,
I have three models: Comatose::Page, Article and Product.
In all of them, store_class_name is set to true.

Now, when i do:
results = Comatose::Page.multi_search("*", [Article,Product], options)
I get:

wrong constant name Comatose::Page

#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:438:in
const_get' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:438:inmulti_search’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:460:in
id_multi_search' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:28:insearch_each’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/multi_index.rb:28:in
search_each' #{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:457:inid_multi_search’
#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:437:in
multi_search' #{RAILS_ROOT}/app/controllers/application.rb:44:inrun_search’
#{RAILS_ROOT}/app/controllers/application.rb:68:in full_text_search' #{RAILS_ROOT}/app/controllers/search_controller.rb:16:inindex’
-e:4:in `load’
-e:4

The ferret index files include the name Comatose::Page and are put in
index/developement/comatose/page directory.

Any idea why I might get that error?
I dont get it with results = Comatose::Page.find_by_contents(q, options)

Best regards,
Tom

On Wed, Mar 21, 2007 at 01:32:37PM +0100, Linus wrote:

#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:438:in
`const_get’
[…]
Any idea why I might get that error?

yeah, const_get can’t resolve namespaced constant names - this issue is
fixed in trunk. If you don’t want to upgrade, replace the call to
const_get with something like

model_class = model_name_string.constantize

(dont know what’s the name of the var holding the model’s name from the
top of my head)

[…]

I dont get it with results = Comatose::Page.find_by_contents(q, options)

that’s because in this case (one-model query) there is no need to lookup
a class based on the model name stored in the index.

cheers,
Jens


Jens Krämer
webit! Gesellschaft für neue Medien mbH
Schnorrstraße 76 | 01069 Dresden
Telefon +49 351 46766-0 | Telefax +49 351 46766-66
[email protected] | www.webit.de

Amtsgericht Dresden | HRB 15422
GF Sven Haubold, Hagen Malessa

Jens K. wrote:

On Wed, Mar 21, 2007 at 01:32:37PM +0100, Linus wrote:

#{RAILS_ROOT}/vendor/plugins/acts_as_ferret/lib/class_methods.rb:438:in
`const_get’
[…]
Any idea why I might get that error?

yeah, const_get can’t resolve namespaced constant names - this issue is
fixed in trunk.

Thank you, trunk works ok :slight_smile:

Best regards,
Tom