rails/acts_as_nested_set — Issue #2: Feature Request: Ability to turn off rebuild per insert
Author: tispratik
Created: 2011-11-30 18:00:42+00:00
State: open

I have a geo data table wherein all the cities are linked to states and states to countries in an hierarchical order. I usually update the data from csv files once a month. During the insert i realized that the inserts are faster when i disable the index rebuild and turn it on again after the inserts. So, the rebuild is v fast if the data does not change.

So, i created a proxy class GeoProxy pointing to the same table to do the inserts which does not have the acts_as_nested_set declaration, so that it does not rebuild on every insert. Then at the end of all the inserts, I call the method Geo.rebuild! from the Geo class which has the acts_as_nested_set declaration.

```ruby
class Geo
acts_as_nested_set
end

class GeoProxy
set_table_name "geos"
end
```

I do the inserts through a rake task using the GeoProxy class and then call Geo.rebuild. It would be good if we can have the ability to turn rebuild per insert on/off so that we dont have to create a proxy class.

Thanks !