There is a bug that I found in better_nested_set.rb, in the before_create() method.
You have:
def before_create
maxright = self.class.count_by_sql("SELECT max(\"#{acts_as_nested_set_options[:right_column]}\") FROM "+self.class.table_name)
# adds the new node to the right of all existing nodes
self[acts_as_nested_set_options[:left_column]] = maxright+1
self[acts_as_nested_set_options[:right_column]] = maxright+2
end
However, this creates a SQL-query like so:
SELECT max("rgt") FROM table
(returns "rgt", not a number
What you really want to do is
SELECT max(rgt) FROM tabl
(returns the actual max() of that column)
Fix the line to look like this:
maxright = self.class.count_by_sql("SELECT max(#{acts_as_nested_set_options[:right_column]}) FROM "+self.class.table_name)
I have tested it, and it will work properly. If you don't fix this, you won't be able to add child objects to parents, as it will throw this error, because lft and rgt clash:
ActiveRecord::ActiveRecordError (Impossible move, target node cannot be inside moved tree.):