To edit pages or tickets please login with username/password: aaf/aaf

Changeset 29

Show
Ignore:
Timestamp:
04/17/06 15:06:05 (3 years ago)
Author:
jk
Message:

make search on subclasses of a single table inheritance model work

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/plugin/acts_as_ferret/lib/acts_as_ferret.rb

    r26 r29  
    212212        # This is called automatically when no index exists yet. 
    213213        # 
    214         # TODO: this only works if every model class has it's  
     214        # TODO: the automatic index initialization only works if  
     215        # every model class has it's  
    215216        # own index, otherwise the index will get populated only 
    216217        # with instances from the first model loaded 
     
    253254          logger.debug "id_array: #{id_array.inspect}" 
    254255          begin 
    255             result = self.find(id_array) 
    256             logger.debug "Result id_array: #{id_array.inspect}, result: #{result}" 
     256            if self.superclass == ActiveRecord::Base 
     257              result = self.find(id_array) 
     258            else 
     259              # no direct subclass of Base --> STI 
     260              # TODO: AR will filter out hits from other classes for us, but this 
     261              # will lead to less results retrieved --> scoping of ferret query 
     262              # to self.class is still needed. 
     263              result = self.find(:all, :conditions => ["id in (?)",id_array]) 
     264            end  
    257265          rescue 
    258266            logger.debug "REBUILD YOUR INDEX! One of the id's didn't have an associated record: #{id_array}" 
    259267          end 
     268          logger.debug "Result id_array: #{id_array.inspect}, result: #{result}" 
    260269          return result 
    261270        end  

To edit pages or tickets please login with username/password: aaf/aaf