# Acts\_as\_ferret - need to remove markup from column first

**URL:** <https://www.ruby-forum.com/t/acts-as-ferret-need-to-remove-markup-from-column-first/150043>\
**Category:** Ferret\
**Created:** [October 2, 2008, 8:00pm UTC](https://www.ruby-forum.com/t/acts-as-ferret-need-to-remove-markup-from-column-first/150043 "2008-10-02T20:00:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![gaudimila](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/87869e/32.png) [@gaudimila](https://www.ruby-forum.com/u/gaudimila)\
**Post date:** [October 2, 2008, 8:00pm UTC](https://www.ruby-forum.com/t/acts-as-ferret-need-to-remove-markup-from-column-first/150043/1 "2008-10-02T20:00:50Z")

</div>

We’re using acts\_as\_ferret on a column called ‘body’ which normally has  
html markup in it. We want to continue to store the markup in our  
database, but we want to remove the markup from that field before Ferret  
indexes it. We’re thinking there would be an option to intercept the  
value that Ferret is indexing, for pre-processing, but we can’t find it.

So we either need to know how Ferret might support this requirement, or,  
we think we can skip the acts\_as\_ferret altogether and manually call  
LocalIndex.add or something like that and therefore have more control  
over what’s being indexed.

Thanks.

---

<div class="post-metadata">

**Author:** ![gaudimila](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/87869e/32.png) [@gaudimila](https://www.ruby-forum.com/u/gaudimila)\
**Post date:** [October 28, 2008, 8:41pm UTC](https://www.ruby-forum.com/t/acts-as-ferret-need-to-remove-markup-from-column-first/150043/2 "2008-10-28T20:41:53Z")

</div>

Hi!

add a ‘virtual field’ to your index that contains the value without  
markup, i.e.

class YourModel  
acts\_as\_ferret :fields =\> [;title, :body\_searchable]

def body\_searchable  
strip\_markup(self.body)  
end  
end

Cheers,  
Jens

Gaudi Mi wrote:

> We’re using acts\_as\_ferret on a column called ‘body’ which normally has  
> html markup in it. We want to continue to store the markup in our  
> database, but we want to remove the markup from that field before Ferret  
> indexes it. We’re thinking there would be an option to intercept the  
> value that Ferret is indexing, for pre-processing, but we can’t find it.
> 
> So we either need to know how Ferret might support this requirement, or,  
> we think we can skip the acts\_as\_ferret altogether and manually call  
> LocalIndex.add or something like that and therefore have more control  
> over what’s being indexed.
> 
> Thanks.
