I have a sellable flag in my database. I’m trying to have ferret only
add/update records where sellable == true. What is the best way to do
this? I’ve tried editing instance_methods.rb in the AAF, but I still
can’t get it to work.
instance_methods.rb#ferret_create
line 85 I changed to:
self.class.ferret_index << self.to_doc if !configure[:ignore_flag] or
self.send(configure[:ignore_flag]) == true
class_methods.rb#rebuild_index
I made the same change to line 199:
index << rec.to_doc if !configure[:ignore_flag] or
self.send(configure[:ignore_flag]) == true
Jens do you think you could add this functionality to AAF in a future
update? It would be much appreciated! Thanks again so much for the
great plugin.
instance_methods.rb#ferret_create
line 85 I changed to:
self.class.ferret_index << self.to_doc if !configure[:ignore_flag] or
self.send(configure[:ignore_flag]) == true
class_methods.rb#rebuild_index
I made the same change to line 199:
index << rec.to_doc if !configure[:ignore_flag] or
self.send(configure[:ignore_flag]) == true
Jens do you think you could add this functionality to AAF in a future
update? It would be much appreciated! Thanks again so much for the
great plugin.
Cheers!
-Ray
Whoops, I made a typo above. Configure should be configuration so the
changes should actually read
instance_methods.rb#ferret_create
line 85 I changed to:
self.class.ferret_index << self.to_doc if !configuration[:ignore_flag]
or
self.send(configuration[:ignore_flag]) == true
class_methods.rb#rebuild_index
I made the same change to line 199:
index << rec.to_doc if !configuration[:ignore_flag] or
self.send(configuration[:ignore_flag]) == true
On Wed, Nov 29, 2006 at 01:55:12AM +0100, Carlos Kozuszko wrote:
I want to do the same in my app. Is there a way to do this without
hacking the plugin code?
not a nice one, but using the disable_ferret method you could build a
custom save method that disables ferret for the next save if some
condition is met, and then saves the record:
def conditional_ferret_save
disable_ferret if do_not_index?
save
end
note that the disable_ferret method disables indexing for this record
for the next call to save - this is definitely not thread safe, but in
a Rails context this usually is not a problem.
However I like the idea of having an :if option to acts_as_ferret to
specify a condition (symbol pointing to a method, or a proc) telling
whether indexing should take place or not.
Jens
–
webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer [email protected]
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.