Well, I guess I'd start by confirming whether your career_levels table has a column named attribute_type.
-- Pat On 21/01/2011, at 11:24 AM, alex wrote: > Same error message! > > > But I can't see what's wrong in my associations: > > class Course < ActiveRecord::Base > ... > has_many :courseattributings, :dependent => :destroy > has_many :career_levels, :through => :courseattributings > ... > end > > class Courseattributing < ActiveRecord::Base > belongs_to :course > belongs_to :career_level, :foreign_key => :attribute_id, > :conditions => > ["attribute_type = ?", 'career_level'] > end > > class CareerLevel < ActiveRecord::Base > has_many :courseattributings, :foreign_key => :attribute_id > has_many :courses, :through => :courseattributings > end > > > Any idea? > > > > > On Jan 20, 4:14 pm, Pat Allan <[email protected]> wrote: >> Hi Alex >> >> What happens if you do a standard #find call and include career levels? >> >> Course.find(:all, :include => :career_levels) >> >> -- >> Pat >> >> On 21/01/2011, at 11:10 AM, alex wrote: >> >> >> >> >> >> >> >>> 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 >>> athttp://groups.google.com/group/thinking-sphinx?hl=en. > > -- > 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. > -- 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.
