Multiple Trees in a better_nested_set Table.

S

Stephen Schor

[Note: parts of this message were removed to make it a legal post.]

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top