From beholdthepanda at gmail.com Mon Jan 14 17:42:03 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Mon, 14 Jan 2008 17:42:03 -0500 Subject: [Betternestedset-talk] Multiple Trees in a Table. Message-ID: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> Hi All, 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 used 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 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080114/ab36b1e5/attachment.html From dontfall at gmail.com Tue Jan 15 00:58:48 2008 From: dontfall at gmail.com (Krishna Dole) Date: Mon, 14 Jan 2008 21:58:48 -0800 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> Message-ID: <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> Hi Stephen, You need to populate the tree_id column for every record. Then things should be fine-- let us know if they aren't. Krishna On Jan 14, 2008 2:42 PM, Stephen Schor wrote: > Hi All, > > 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 used 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 > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > From beholdthepanda at gmail.com Tue Jan 15 09:39:59 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Tue, 15 Jan 2008 09:39:59 -0500 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> Message-ID: <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> Hi Krishna, Thanks for the quick reply! I still get a MySQL error. My class looks like: class Study < ActiveRecord::Base acts_as_nested_set :scope => :tree_id ... end Here's a snippit from a (typically frustrating) script/console session using an empty table: >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) => #"Grandpa", "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> >> s1.valid? => true >> s1.save ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") -Thanks again, Stephen On Jan 15, 2008 12:58 AM, Krishna Dole wrote: > Hi Stephen, > > You need to populate the tree_id column for every record. Then things > should be fine-- let us know if they aren't. > > Krishna > > On Jan 14, 2008 2:42 PM, Stephen Schor wrote: > > Hi All, > > > > 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 used 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 > > > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080115/29c6a5f1/attachment.html From beholdthepanda at gmail.com Tue Jan 15 11:35:05 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Tue, 15 Jan 2008 11:35:05 -0500 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> Message-ID: <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> Sorry for the double-email but I was looking line 79 of better_nested_set.rb: options[:scope] = %(#{options[:scope].to_s}.nil? ? "#{options[:scope].to_s} IS NULL" : "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") This sets options[:scope] to be a string of ruby code, rather than SQL. For instance, if options[:scope] was :tree_id, the above would evaluate to: 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' And this string is then put into acts_as_nested_set_options on line 88. On Jan 15, 2008 9:39 AM, Stephen Schor wrote: > Hi Krishna, > > Thanks for the quick reply! I still get a MySQL error. > My class looks like: > > class Study < ActiveRecord::Base > acts_as_nested_set :scope => :tree_id > ... > end > > Here's a snippit from a (typically frustrating) script/console session > using an empty table: > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > => #"Grandpa", > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > >> s1.valid? > => true > > >> s1.save > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > -Thanks again, > Stephen > > > > On Jan 15, 2008 12:58 AM, Krishna Dole wrote: > > > Hi Stephen, > > > > You need to populate the tree_id column for every record. Then things > > should be fine-- let us know if they aren't. > > > > Krishna > > > > On Jan 14, 2008 2:42 PM, Stephen Schor > > wrote: > > > Hi All, > > > > > > 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/BetterNestedSetas a > > > guide and created > > > a tree_id column in my table and used 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 > > > > > > _______________________________________________ > > > Betternestedset-talk mailing list > > > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080115/65e5b732/attachment-0001.html From beholdthepanda at gmail.com Wed Jan 16 09:47:10 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Wed, 16 Jan 2008 09:47:10 -0500 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> Message-ID: <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> UPDATE: Thanks for the help on this Krishna. I think my project was using an old or self-hacked version of the plugin. I've reinstalled it and all seems well. -Stephen On Jan 15, 2008 11:35 AM, Stephen Schor wrote: > Sorry for the double-email but I was looking line 79 of > better_nested_set.rb: > options[:scope] = %(#{options[:scope].to_s}.nil? ? > "#{options[:scope].to_s} IS NULL" : > "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") > > This sets options[:scope] to be a string of ruby code, rather than SQL. > For instance, if options[:scope] was :tree_id, the above would evaluate > to: > > 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' > > And this string is then put into acts_as_nested_set_options on line 88. > > > > On Jan 15, 2008 9:39 AM, Stephen Schor wrote: > > > Hi Krishna, > > > > Thanks for the quick reply! I still get a MySQL error. > > My class looks like: > > > > class Study < ActiveRecord::Base > > acts_as_nested_set :scope => :tree_id > > ... > > end > > > > Here's a snippit from a (typically frustrating) script/console session > > using an empty table: > > > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > > => #"Grandpa", > > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > > > >> s1.valid? > > => true > > > > >> s1.save > > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE > > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > > > -Thanks again, > > Stephen > > > > > > > > On Jan 15, 2008 12:58 AM, Krishna Dole < dontfall at gmail.com > wrote: > > > > > Hi Stephen, > > > > > > You need to populate the tree_id column for every record. Then things > > > should be fine-- let us know if they aren't. > > > > > > Krishna > > > > > > On Jan 14, 2008 2:42 PM, Stephen Schor > > > wrote: > > > > Hi All, > > > > > > > > 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 used 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 > > > > > > > > _______________________________________________ > > > > Betternestedset-talk mailing list > > > > Betternestedset-talk at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > _______________________________________________ > > > Betternestedset-talk mailing list > > > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080116/3531436c/attachment.html From peter at flippyhead.com Wed Jan 16 13:20:12 2008 From: peter at flippyhead.com (Peter Brown) Date: Wed, 16 Jan 2008 10:20:12 -0800 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> Message-ID: hmmm, I am having this exact problem with the latest BNS on Rails 2.02. Should this work on 2.02? It appears as though AR isn't interpolating strings the way it used to. On 1/16/08, Stephen Schor wrote: > UPDATE: > > Thanks for the help on this Krishna. I think my project was using an old or > self-hacked version of the plugin. > I've reinstalled it and all seems well. > > -Stephen > > On Jan 15, 2008 11:35 AM, Stephen Schor wrote: > > Sorry for the double-email but I was looking line 79 of > better_nested_set.rb: > > options[:scope] = %(#{options[:scope].to_s}.nil? ? > "#{options[:scope].to_s} IS NULL" : > > "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") > > > > This sets options[:scope] to be a string of ruby code, rather than SQL. > > For instance, if options[:scope] was :tree_id, the above would evaluate > > to: > > > > 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' > > > > And this string is then put into acts_as_nested_set_options on line 88. > > > > > > > > > > > > > > On Jan 15, 2008 9:39 AM, Stephen Schor wrote: > > > > > Hi Krishna, > > > > > > Thanks for the quick reply! I still get a MySQL error. > > > My class looks like: > > > > > > class Study < ActiveRecord::Base > > > > > > acts_as_nested_set :scope => :tree_id > > > ... > > > end > > > > > > Here's a snippit from a (typically frustrating) script/console session > using an empty table: > > > > > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > > > => #"Grandpa", > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > > > > > >> s1.valid? > > > => true > > > > > > >> s1.save > > > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > > > > > -Thanks again, > > > Stephen > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 12:58 AM, Krishna Dole < dontfall at gmail.com > wrote: > > > > > > > Hi Stephen, > > > > > > > > You need to populate the tree_id column for every record. Then things > > > > should be fine-- let us know if they aren't. > > > > > > > > Krishna > > > > > > > > > > > > > > > > > > > > On Jan 14, 2008 2:42 PM, Stephen Schor > wrote: > > > > > Hi All, > > > > > > > > > > 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 used 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 > > > > > > > > > > _______________________________________________ > > > > > Betternestedset-talk mailing list > > > > > Betternestedset-talk at rubyforge.org > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > _______________________________________________ > > > > Betternestedset-talk mailing list > > > > Betternestedset-talk at rubyforge.org > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > -- Peter T. Brown peter at wagglelabs.com http://wagglelabs.com From dontfall at gmail.com Wed Jan 16 13:43:38 2008 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 16 Jan 2008 10:43:38 -0800 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> Message-ID: <8d64b97d0801161043y2024cda4t3cdb50403739abe7@mail.gmail.com> Are you using the trunk version of BNS? k On Jan 16, 2008 10:20 AM, Peter Brown wrote: > hmmm, I am having this exact problem with the latest BNS on Rails 2.02. > > Should this work on 2.02? It appears as though AR isn't interpolating > strings the way it used to. > > > On 1/16/08, Stephen Schor wrote: > > UPDATE: > > > > Thanks for the help on this Krishna. I think my project was using an old or > > self-hacked version of the plugin. > > I've reinstalled it and all seems well. > > > > -Stephen > > > > On Jan 15, 2008 11:35 AM, Stephen Schor wrote: > > > Sorry for the double-email but I was looking line 79 of > > better_nested_set.rb: > > > options[:scope] = %(#{options[:scope].to_s}.nil? ? > > "#{options[:scope].to_s} IS NULL" : > > > "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") > > > > > > This sets options[:scope] to be a string of ruby code, rather than SQL. > > > For instance, if options[:scope] was :tree_id, the above would evaluate > > > to: > > > > > > 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' > > > > > > And this string is then put into acts_as_nested_set_options on line 88. > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 9:39 AM, Stephen Schor wrote: > > > > > > > Hi Krishna, > > > > > > > > Thanks for the quick reply! I still get a MySQL error. > > > > My class looks like: > > > > > > > > class Study < ActiveRecord::Base > > > > > > > > acts_as_nested_set :scope => :tree_id > > > > ... > > > > end > > > > > > > > Here's a snippit from a (typically frustrating) script/console session > > using an empty table: > > > > > > > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > > > > => #"Grandpa", > > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > > > > > > > >> s1.valid? > > > > => true > > > > > > > > >> s1.save > > > > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE > > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > > > > > > > -Thanks again, > > > > Stephen > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 12:58 AM, Krishna Dole < dontfall at gmail.com > wrote: > > > > > > > > > Hi Stephen, > > > > > > > > > > You need to populate the tree_id column for every record. Then things > > > > > should be fine-- let us know if they aren't. > > > > > > > > > > Krishna > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 14, 2008 2:42 PM, Stephen Schor > > wrote: > > > > > > Hi All, > > > > > > > > > > > > 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 used 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 > > > > > > > > > > > > _______________________________________________ > > > > > > Betternestedset-talk mailing list > > > > > > Betternestedset-talk at rubyforge.org > > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > Betternestedset-talk mailing list > > > > > Betternestedset-talk at rubyforge.org > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > -- > Peter T. Brown > peter at wagglelabs.com > http://wagglelabs.com > _______________________________________________ > > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > From peter at flippyhead.com Wed Jan 16 13:51:29 2008 From: peter at flippyhead.com (Peter Brown) Date: Wed, 16 Jan 2008 10:51:29 -0800 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: <8d64b97d0801161043y2024cda4t3cdb50403739abe7@mail.gmail.com> References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> <8d64b97d0801161043y2024cda4t3cdb50403739abe7@mail.gmail.com> Message-ID: You know, I'm not really sure. I've seen URL's for the trunk both on opensource.symetrie.com and on rubyforge.org. What URL should I be using? On 1/16/08, Krishna Dole wrote: > Are you using the trunk version of BNS? > > k > > On Jan 16, 2008 10:20 AM, Peter Brown wrote: > > hmmm, I am having this exact problem with the latest BNS on Rails 2.02. > > > > Should this work on 2.02? It appears as though AR isn't interpolating > > strings the way it used to. > > > > > > On 1/16/08, Stephen Schor wrote: > > > UPDATE: > > > > > > Thanks for the help on this Krishna. I think my project was using an old or > > > self-hacked version of the plugin. > > > I've reinstalled it and all seems well. > > > > > > -Stephen > > > > > > On Jan 15, 2008 11:35 AM, Stephen Schor wrote: > > > > Sorry for the double-email but I was looking line 79 of > > > better_nested_set.rb: > > > > options[:scope] = %(#{options[:scope].to_s}.nil? ? > > > "#{options[:scope].to_s} IS NULL" : > > > > "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") > > > > > > > > This sets options[:scope] to be a string of ruby code, rather than SQL. > > > > For instance, if options[:scope] was :tree_id, the above would evaluate > > > > to: > > > > > > > > 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' > > > > > > > > And this string is then put into acts_as_nested_set_options on line 88. > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 9:39 AM, Stephen Schor wrote: > > > > > > > > > Hi Krishna, > > > > > > > > > > Thanks for the quick reply! I still get a MySQL error. > > > > > My class looks like: > > > > > > > > > > class Study < ActiveRecord::Base > > > > > > > > > > acts_as_nested_set :scope => :tree_id > > > > > ... > > > > > end > > > > > > > > > > Here's a snippit from a (typically frustrating) script/console session > > > using an empty table: > > > > > > > > > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > > > > > => #"Grandpa", > > > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > > > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > > > > > > > > > >> s1.valid? > > > > > => true > > > > > > > > > > >> s1.save > > > > > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies WHERE > > > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > > > > > > > > > -Thanks again, > > > > > Stephen > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 12:58 AM, Krishna Dole < dontfall at gmail.com > wrote: > > > > > > > > > > > Hi Stephen, > > > > > > > > > > > > You need to populate the tree_id column for every record. Then things > > > > > > should be fine-- let us know if they aren't. > > > > > > > > > > > > Krishna > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 14, 2008 2:42 PM, Stephen Schor > > > wrote: > > > > > > > Hi All, > > > > > > > > > > > > > > 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 used 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 > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Betternestedset-talk mailing list > > > > > > > Betternestedset-talk at rubyforge.org > > > > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > Betternestedset-talk mailing list > > > > > > Betternestedset-talk at rubyforge.org > > > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > Betternestedset-talk mailing list > > > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > -- > > Peter T. Brown > > peter at wagglelabs.com > > http://wagglelabs.com > > _______________________________________________ > > > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -- Peter T. Brown peter at wagglelabs.com http://wagglelabs.com From beholdthepanda at gmail.com Wed Jan 16 17:16:18 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Wed, 16 Jan 2008 17:16:18 -0500 Subject: [Betternestedset-talk] Multiple Trees in a Table. In-Reply-To: References: <45e5e9bc0801141442y4b667efco2a256ba6a5e1b39a@mail.gmail.com> <8d64b97d0801142158s535bd961p7a471a24100ca3c0@mail.gmail.com> <45e5e9bc0801150639i6dc628codaebf7181811c486@mail.gmail.com> <45e5e9bc0801150835q157a8949o8fa2be9d6010dc8e@mail.gmail.com> <45e5e9bc0801160647n6fc4aee5yf61755274ca030bb@mail.gmail.com> <8d64b97d0801161043y2024cda4t3cdb50403739abe7@mail.gmail.com> Message-ID: <45e5e9bc0801161416i6fe1208fo2b21b00055ad8aff@mail.gmail.com> My sucsessful install was done by adding the repository to my script/install repository and runing script/install/betternestedset script/plugin source svn://rubyforge.org/var/svn/betternestedset script/plugin install betternestedset On Jan 16, 2008 1:51 PM, Peter Brown wrote: > You know, I'm not really sure. I've seen URL's for the trunk both on > opensource.symetrie.com and on rubyforge.org. > > What URL should I be using? > > > > On 1/16/08, Krishna Dole wrote: > > Are you using the trunk version of BNS? > > > > k > > > > On Jan 16, 2008 10:20 AM, Peter Brown wrote: > > > hmmm, I am having this exact problem with the latest BNS on Rails 2.02 > . > > > > > > Should this work on 2.02? It appears as though AR isn't interpolating > > > strings the way it used to. > > > > > > > > > On 1/16/08, Stephen Schor wrote: > > > > UPDATE: > > > > > > > > Thanks for the help on this Krishna. I think my project was using > an old or > > > > self-hacked version of the plugin. > > > > I've reinstalled it and all seems well. > > > > > > > > -Stephen > > > > > > > > On Jan 15, 2008 11:35 AM, Stephen Schor > wrote: > > > > > Sorry for the double-email but I was looking line 79 of > > > > better_nested_set.rb: > > > > > options[:scope] = %(#{options[:scope].to_s}.nil? ? > > > > "#{options[:scope].to_s} IS NULL" : > > > > > "#{options[:scope].to_s} = \#{#{options[:scope].to_s}}") > > > > > > > > > > This sets options[:scope] to be a string of ruby code, rather than > SQL. > > > > > For instance, if options[:scope] was :tree_id, the above would > evaluate > > > > > to: > > > > > > > > > > 'tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}"' > > > > > > > > > > And this string is then put into acts_as_nested_set_options on > line 88. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 9:39 AM, Stephen Schor > wrote: > > > > > > > > > > > Hi Krishna, > > > > > > > > > > > > Thanks for the quick reply! I still get a MySQL error. > > > > > > My class looks like: > > > > > > > > > > > > class Study < ActiveRecord::Base > > > > > > > > > > > > acts_as_nested_set :scope => :tree_id > > > > > > ... > > > > > > end > > > > > > > > > > > > Here's a snippit from a (typically frustrating) script/console > session > > > > using an empty table: > > > > > > > > > > > > >> s1 = Study.new(:name=>'Grandpa', :oid=>123,:tree_id=>1) > > > > > > => # @attributes={"name"=>"Grandpa", > > > > "updated_at"=>nil, "lock_version"=>0, "lft"=>nil, "tree_id"=>1, > > > > "parent_id"=>nil, "rgt"=>nil, "oid"=>123, "created_at"=>nil}> > > > > > > > > > > > > >> s1.valid? > > > > > > => true > > > > > > > > > > > > >> s1.save > > > > > > ActiveRecord::StatementInvalid: 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}")' at line 1: SELECT max(rgt) AS max_rgt FROM studies > WHERE > > > > (tree_id.nil? ? "tree_id IS NULL" : "tree_id = #{tree_id}") > > > > > > > > > > > > -Thanks again, > > > > > > Stephen > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 15, 2008 12:58 AM, Krishna Dole < dontfall at gmail.com > > wrote: > > > > > > > > > > > > > Hi Stephen, > > > > > > > > > > > > > > You need to populate the tree_id column for every record. Then > things > > > > > > > should be fine-- let us know if they aren't. > > > > > > > > > > > > > > Krishna > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > On Jan 14, 2008 2:42 PM, Stephen Schor < > beholdthepanda at gmail.com > > > > > wrote: > > > > > > > > Hi All, > > > > > > > > > > > > > > > > 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 used 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 > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > > Betternestedset-talk mailing list > > > > > > > > Betternestedset-talk at rubyforge.org > > > > > > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Betternestedset-talk mailing list > > > > > > > Betternestedset-talk at rubyforge.org > > > > > > > > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > Betternestedset-talk mailing list > > > > Betternestedset-talk at rubyforge.org > > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > > > > > > > > > > > > > -- > > > Peter T. Brown > > > peter at wagglelabs.com > > > http://wagglelabs.com > > > _______________________________________________ > > > > > > Betternestedset-talk mailing list > > > Betternestedset-talk at rubyforge.org > > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > -- > Peter T. Brown > peter at wagglelabs.com > http://wagglelabs.com > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080116/8b87aa7c/attachment.html From beholdthepanda at gmail.com Wed Jan 30 17:44:51 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Wed, 30 Jan 2008 17:44:51 -0500 Subject: [Betternestedset-talk] move_to_child_of() on existing records. Message-ID: <45e5e9bc0801301444n377d57e0vac75e3615e74ca40@mail.gmail.com> Hey all, I have a quick question about some weirdo behavior I'm seeing in my tables. I have a table that looks like: ID NAME LFT RGT PARENT_ID TREE_ID 18 dogs 1 2 null 18 19 cats 1 4 null 19 20 smalldogs 2 3 19 19 and say to myself 'oops' - smalldogs is really a child of 'dogs.' - not cats opening up a script/console session I play around with the records... >> t = Team.find(20) => # >> t.tree_id = 18 => 18 >> t.save => true >> t.move_to_child_of(Team.find(18)) => nil My table ends up looking like ID NAME LFT RGT PARENT_ID TREE_ID 18 dogs 1 2 null 18 19 cats 1 4 null 19 20 smalldogs 2 3 19 18 So it's a little weird that smalldog.parent_id and dogs.lft/rgt weren't adjusted after calling move_to_child_of. So - is there a common pattern for moving existing nodes into other trees when using the scope option? Thanks! -Stephen -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080130/3cab7014/attachment.html From dontfall at gmail.com Wed Jan 30 20:49:36 2008 From: dontfall at gmail.com (Krishna Dole) Date: Wed, 30 Jan 2008 17:49:36 -0800 Subject: [Betternestedset-talk] move_to_child_of() on existing records. In-Reply-To: <45e5e9bc0801301444n377d57e0vac75e3615e74ca40@mail.gmail.com> References: <45e5e9bc0801301444n377d57e0vac75e3615e74ca40@mail.gmail.com> Message-ID: <8d64b97d0801301749j16211a15o7bc26a3388cbb08e@mail.gmail.com> Hi Stephen, Currently the API does not support moving nodes between trees. You may want to make sure you are using the trunk version of the code since I vaguely recall putting a check in there that would raise if you tried to move nodes between trees. Or maybe I just imagined it. Krishna On Jan 30, 2008 2:44 PM, Stephen Schor wrote: > Hey all, > > I have a quick question about some weirdo behavior I'm seeing in my tables. > I have a table that looks like: > > ID NAME LFT RGT PARENT_ID TREE_ID > 18 dogs 1 2 null 18 > 19 cats 1 4 null 19 > 20 smalldogs 2 3 19 19 > > and say to myself 'oops' - smalldogs is really a child of 'dogs.' - not cats > opening up a script/console session I play around with the records... > > >> t = Team.find(20) > => # tree_id: 19> > >> t.tree_id = 18 > => 18 > >> t.save > => true > >> t.move_to_child_of(Team.find(18)) > => nil > > My table ends up looking like > ID NAME LFT RGT PARENT_ID TREE_ID > 18 dogs 1 2 null 18 > 19 cats 1 4 null 19 > 20 smalldogs 2 3 19 18 > > So it's a little weird that smalldog.parent_id and dogs.lft/rgt weren't > adjusted after calling move_to_child_of. > So - is there a common pattern for moving existing nodes into other trees > when using the scope option? > > Thanks! > -Stephen > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > From beholdthepanda at gmail.com Wed Jan 30 22:23:53 2008 From: beholdthepanda at gmail.com (Stephen Schor) Date: Wed, 30 Jan 2008 22:23:53 -0500 Subject: [Betternestedset-talk] move_to_child_of() on existing records. In-Reply-To: <8d64b97d0801301749j16211a15o7bc26a3388cbb08e@mail.gmail.com> References: <45e5e9bc0801301444n377d57e0vac75e3615e74ca40@mail.gmail.com> <8d64b97d0801301749j16211a15o7bc26a3388cbb08e@mail.gmail.com> Message-ID: <45e5e9bc0801301923l7f0e980cxdbaff458853e0385@mail.gmail.com> Hi Krishna, Thanks so much for the quick response - I really appreciate it. I'll take double check that I've got the latest and greatest. (I may be using a version from /tags/stable). -Stephen On Jan 30, 2008 8:49 PM, Krishna Dole wrote: > Hi Stephen, > > Currently the API does not support moving nodes between trees. > > You may want to make sure you are using the trunk version of the code > since I vaguely recall putting a check in there that would raise if > you tried to move nodes between trees. Or maybe I just imagined it. > > Krishna > > On Jan 30, 2008 2:44 PM, Stephen Schor wrote: > > Hey all, > > > > I have a quick question about some weirdo behavior I'm seeing in my > tables. > > I have a table that looks like: > > > > ID NAME LFT RGT PARENT_ID TREE_ID > > 18 dogs 1 2 null 18 > > 19 cats 1 4 null 19 > > 20 smalldogs 2 3 19 19 > > > > and say to myself 'oops' - smalldogs is really a child of 'dogs.' - not > cats > > opening up a script/console session I play around with the records... > > > > >> t = Team.find(20) > > => # > tree_id: 19> > > >> t.tree_id = 18 > > => 18 > > >> t.save > > => true > > >> t.move_to_child_of(Team.find(18)) > > => nil > > > > My table ends up looking like > > ID NAME LFT RGT PARENT_ID TREE_ID > > 18 dogs 1 2 null 18 > > 19 cats 1 4 null 19 > > 20 smalldogs 2 3 19 18 > > > > So it's a little weird that smalldog.parent_id and dogs.lft/rgt weren't > > adjusted after calling move_to_child_of. > > So - is there a common pattern for moving existing nodes into other > trees > > when using the scope option? > > > > Thanks! > > -Stephen > > > > _______________________________________________ > > Betternestedset-talk mailing list > > Betternestedset-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/betternestedset-talk > > > > > _______________________________________________ > Betternestedset-talk mailing list > Betternestedset-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/betternestedset-talk > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080130/793d76cc/attachment.html