I have been using ThinkingSphinx in an application for a while, and
now I wanted to keep a log of user searches, search strings and
results and correlate this to what the user ends up purchasing on the
site.

Using the database for logging, I settled on the following models:

class Search < ActiveRecord::Base
  has_many :search_criteria
end

class SearchCriterion < ActiveRecord::Base
  belongs_to :search
end

Now, when going through the belongs_to association,
ThinkingSphinx::ActiveRecord::Search takes precedence over my model
class Search:

>> sc = SearchCriterion.first
=> #<SearchCriterion search_id: 145, field: :title, id: 1,
search_string_id: 309>

>> sc.search
NoMethodError: undefined method `find' for
ThinkingSphinx::ActiveRecord::Search:Module
        from vendor/rails/activerecord/lib/active_record/associations/
belongs_to_association.rb:44:in `find_target'
        from vendor/rails/activerecord/lib/active_record/associations/
association_proxy.rb:233:in `load_target'
        from vendor/rails/activerecord/lib/active_record/associations/
association_proxy.rb:112:in `reload'
        from vendor/rails/activerecord/lib/active_record/associations.rb:
1249:in `search'
        from (irb):10

Any views on how to correct this?
 - Rename ThinkingSphinx::ActiveRecord::Search to e.g.
ThinkingSphinx::ActiveRecord::SphinxSearch?
 - Put my models in a namespace?
 - Rename my model?
 - Revise Rails' behavior in ActiveRecord::Base#compute_type?

Best regards

Christian

--~--~---------~--~----~------------~-------~--~----~
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