Changeset 324 for trunk/demo
- Timestamp:
- 02/18/08 20:36:07 (8 months ago)
- Files:
-
- trunk/demo/app/models/comment.rb (modified) (2 diffs)
- trunk/demo/test/unit/comment_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/demo/app/models/comment.rb
r321 r324 27 27 # the :ignore flag tells aaf to not try to set this field's value itself (we 28 28 # 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? }, 30 30 :fields => { 31 31 :content => { :store => :yes }, … … 36 36 #}, :ferret => { :analyzer => PlainAsciiAnalyzer.new(['fax', 'gsm', 'the', 'or']) } ) 37 37 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 40 41 41 42 # you can override the default to_doc method trunk/demo/test/unit/comment_test.rb
r319 r324 11 11 def test_truth 12 12 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 13 19 end 14 20
