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
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 > >
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)=> #<Study:0x23f7814 @new_record=true, @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.saveActiveRecord::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 >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080115/29c6a5f1/attachment.html
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 <beholdthepanda at gmail.com> 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) > => #<Study:0x23f7814 @new_record=true, @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/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
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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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) > > => #<Study:0x23f7814 @new_record=true, @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 > > > > > > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/betternestedset-talk/attachments/20080116/3531436c/attachment.html
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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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) > > > => #<Study:0x23f7814 @new_record=true, @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
Are you using the trunk version of BNS? k On Jan 16, 2008 10:20 AM, Peter Brown <peter at flippyhead.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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) > > > > => #<Study:0x23f7814 @new_record=true, @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 >
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 <dontfall at gmail.com> wrote:> Are you using the trunk version of BNS? > > k > > On Jan 16, 2008 10:20 AM, Peter Brown <peter at flippyhead.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> 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) > > > > > => #<Study:0x23f7814 @new_record=true, @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
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 <peter at flippyhead.com> 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 <dontfall at gmail.com> wrote: > > Are you using the trunk version of BNS? > > > > k > > > > On Jan 16, 2008 10:20 AM, Peter Brown <peter at flippyhead.com> 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 <beholdthepanda at gmail.com> 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 <beholdthepanda at gmail.com> > 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 <beholdthepanda at gmail.com> > 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) > > > > > > => #<Study:0x23f7814 @new_record=true, > @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