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

Changeset 7

Show
Ignore:
Timestamp:
03/03/06 10:38:02 (3 years ago)
Author:
jk
Message:

Patch: automatic creation of non-existing index (Kasper Weibel)

Files:

Legend:

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

    r1 r7  
    184184            EOV 
    185185            FerretMixin::Acts::ARFerret::ensure_directory configuration[:index_dir] 
    186           end                    
     186            rebuild_index unless File.file? "#{configuration[:index_dir]}/segments" 
     187          end 
     188 
     189          def rebuild_index 
     190            index = Ferret::Index::Index.new(:path => class_index_dir, :create => true) 
     191            self.find_all.each { |content| index << content.to_doc } 
     192            logger.debug("Created Ferret index in: #{class_index_dir}") 
     193            index.flush 
     194            index.optimize 
     195            index.close 
     196          end                                                             
    187197 
    188198          # Index instances are stored in a hash, using the index directory 

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