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

Changeset 324 for trunk/demo

Show
Ignore:
Timestamp:
02/18/08 20:36:07 (8 months ago)
Author:
jk
Message:

add :if option to acts_as_ferret method

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demo/app/models/comment.rb

    r321 r324  
    2727  # the :ignore flag tells aaf to not try to set this field's value itself (we 
    2828  # do this in our custom to_doc method) 
    29   acts_as_ferret( :store_class_name => true,  
     29  acts_as_ferret( :if => Proc.new { |comment| comment.do_index? }, 
    3030                  :fields => { 
    3131                    :content => { :store => :yes }, 
     
    3636                  #}, :ferret => { :analyzer => PlainAsciiAnalyzer.new(['fax', 'gsm', 'the', 'or']) } ) 
    3737 
    38   # only index the named fields: 
    39   #acts_as_ferret :fields => [:author, :content ] 
     38  def do_index? 
     39    self.content !~ /do not index/ 
     40  end 
    4041 
    4142  # you can override the default to_doc method  
  • trunk/demo/test/unit/comment_test.rb

    r319 r324  
    1111  def test_truth 
    1212    assert_kind_of Comment, comments(:first) 
     13  end 
     14 
     15  def test_if_option 
     16    c = Comment.new :content => 'do not index' 
     17    c.save 
     18    assert_equal 0, Comment.find_with_ferret('do not index').total_hits 
    1319  end 
    1420 

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