Multiple Trees in a better_nested_set Table

Hi All,

I also sent this message out to the better_nested_set mailing list so
I’ll
update this thread
if that yields a response.

I’m having trouble configuring a table to be able to accommodate
multiple
trees.
I have a feeling that this is a common question but a few creative
searches
came up empty.
I tried using http://wiki.rubyonrails.org/rails/pages/BetterNestedSet as
a
guide and created
a tree_id column in my table and declared acts_as_nested_set, :scope =>
:tree_id in my model.

My rspec tests began failing and reporting the MYSQL error below:

*Mysql::Error: #42000You have an error in your SQL syntax; check the
manual that corresponds to your MySQL server version for the right
syntax to use near ‘? ? “tree_id IS NULL” : “tree_id = #{tree_id}” AND
(parent_id IS NULL)) ORDER B’ at line 1: SELECT * FROM studies WHERE
(tree_id.nil? ? “tree_id IS NULL” : “tree_id = #{tree_id}” AND
(parent_id IS NULL)) ORDER BY lft
*
Any insight is greatly appreciated. I guess I’m a bit hazy on what
:scope
is used for and how to use it.
I’ve also played around with making multiple trees without :scope in my
directive and it most of my method calls
ended up looking like I’d expect. (.root? and .root got weird on me)

-Thanks!
Stephen

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs