I'm trying to use RUR (Rails Undo Redo, http://blog.nanorails.com/rails-undo-redo) on a model which uses BNS.
Unfortunately performing an undo after deleting an element from the bns-tree isn't working. This is due to the fact that lft, rght and parent_id are not writeable. While I can see that lft and rght are definitly better left alone, I don't see the reason for not making parent_id accessible. I'm sure we can implement bns in such a way that this wouldn't make it less error-prone.
I already took the liberty to modify my local bns copy to do exactly that. More precisly I followed the suggestion made on http://wiki.rubyonrails.org/rails/pages/BetterNestedSet.
The following code changes were done:
a) removed "acts_as_nested_set_options[:parent_column].intern"
b) removed "def #{acts_as_nested_set_options[:parent_column]}=(x)...."
c) added after create:
def after_create
if self[parent_col_name]
parent = self.class.find_by_id(self[parent_col_name])
self.move_to_child_of( parent ) if parent
end
end
Best regards
Johannes