Hi,

I am happily using sphinx for searching but just ran into a small
problem:

My main model is defined as follow:

class Course
  has_many  :tracks, :dependent => :destroy,
                               :order => "tracks.from_date"
  has_many  :courseattributings, :dependent => :destroy
  has_many  :career_levels,       :through => :courseattributings
  has_many  :coursetopicings, :dependent => :destroy
  has_many  :topics,               :through => :coursetopicings

  ...

  define_index do
    indexes     :name,
                    :sortable   => :true
    indexes     objectives
    has           topics(:id),  :as         => :topic_ids,
                                     :facet      => true
    has           career_levels(:id),         :as
=> :career_level_ids

    has       tracks(:from_date),         :as
=> :track_from_dates,
                                                    :type
=> :datetime
    has       tracks(:to_date),            :as
=> :track_to_dates,
                                                    :type
=> :datetime
    ...
  end

end


When I do:

    @courses = Course.search(
      keywords,
      :with       => with_params,
      :sort_mode  => sort_params[:sort_mode],
      :order      => sort_params[:order],
      :per_page   => 10,
      :page => (params[:page] || 1),
      :include => [:topics, :career_levels, :tracks]
    )

I get the following error message:

ActiveRecord::StatementInvalid (Mysql::Error: Unknown column
'attribute_type' in 'where clause': SELECT * FROM `career_levels`
WHERE (`career_levels`.`id` IN (6,4,5) AND (attribute_type =
'career_level')) ):
  /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.3.11/lib/
thinking_sphinx/search.rb:637:in `instances_from_class'
  /Library/Ruby/Gems/1.8/gems/thinking-sphinx-1.3.11/lib/
thinking_sphinx/search.rb:690:in `single_class_results'


If I remove "career_levels" from the "include" statement, everything
works fine. What am I missing?

Thanks for your help!

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