Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Failing when requesting siblings #8

Merged
merged 1 commit into from

2 participants

@eljojo

Hi,
closure_tree was crashing when requesting siblings for a specific row.

1.9.3-p125 :006 > creativity = Tag.find 10
Tag Load (0.4ms) SELECT tags.* FROM tags WHERE tags.id = 10 ORDER BY tags.title ASC LIMIT 1
=> #
1.9.3-p125 :008 > creativity.parent
Tag Load (0.4ms) SELECT tags.* FROM tags WHERE tags.id = 26 ORDER BY tags.title ASC LIMIT 1
=> #
1.9.3-p125 :009 > creativity.siblings
Tag Load (0.6ms) SELECT tags.* FROM tags WHERE tags.parent = 26 AND (tags.id != 10) ORDER BY tags.title ASC
ActiveRecord::StatementInvalid: Mysql2::Error: Unknown column 'tags.parent' in 'where clause': SELECT tags.* FROM tags WHERE tags.parent = 26 AND (tags.id != 10) ORDER BY tags.title ASC

@mceachen
Owner

Good catch, and thanks for the pull request!

We obviously need a test for siblings() -- I'll be able to get to that in a day or two, unless you can throw it together.

@mceachen mceachen merged commit adfadd9 into mceachen:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  lib/closure_tree/acts_as_tree.rb
View
2  lib/closure_tree/acts_as_tree.rb
@@ -120,7 +120,7 @@ def descendants
end
def self_and_siblings
- self.class.scoped.where(:parent => parent)
+ self.class.scoped.where(:parent_id => parent)
end
def siblings
Something went wrong with that request. Please try again.