lib/pg_search/multisearch.rb in pg_search-0.5 vs lib/pg_search/multisearch.rb in pg_search-0.5.1

- old
+ new

@@ -11,13 +11,17 @@ :current_time AS updated_at FROM :model_table SQL class << self - def rebuild(model) + def rebuild(model, clean_up=true) model.transaction do - PgSearch::Document.where(:searchable_type => model.name).delete_all - model.connection.execute(rebuild_sql(model)) + PgSearch::Document.where(:searchable_type => model.name).delete_all if clean_up + if model.respond_to?(:rebuild_pg_search_documents) + model.rebuild_pg_search_documents + else + model.connection.execute(rebuild_sql(model)) + end end end def rebuild_sql(model) connection = model.connection