Possible missing results #15

Closed
manutero opened this Issue Aug 24, 2012 · 7 comments

Comments

Projects
None yet
2 participants

Hi, I was working with Closure-tree gem and I noticed this

1.9.3p194 :019 > m.self_and_ancestors
=> [# CuisineType id: 27, name: "m", parent_id: 22 ]

so we have "m" with a parent... not in the list

1.9.3p194 :020 > m.parent
=> # CuisineType id: 22, name: "e", parent_id: nil

For me, the "logic" behaviour should be smth like
console > m.self_and_ancestors
=> [# ...m..., #...e...]

At least I've resolved it creating my own function (recursive simple one). I've posted it just for "help the developers if it were really a bug"

Apart from that the gem is sooo nice ^^

Manu

Collaborator

mceachen commented Aug 26, 2012

Hey there, I can't reproduce your issue -- see 7d6a7a2...798a56d

and

http://travis-ci.org/#!/mceachen/closure_tree/builds/2239812

Can you edit that new test to be more like your setup, and make it fail?

Thanks.

@mceachen mceachen closed this Aug 27, 2012

Collaborator

mceachen commented Aug 27, 2012

(I'm happy to re-open this issue if you can write a test that reproduces your bug, or explains your problem better)

Hi there,

I run a console, and I create a father object, lets call him {parent}.
Then i create a {child} object passing the {parent} id

If i call the parent method on {child} i'll receive {parent}, everything looks fine.

But if i call child.self_and_ancestors I expected smth like [ {child}, {parent} ] instead of []

Collaborator

mceachen commented Aug 29, 2012

OK, I see. I've changed my test to do what I think you're doing. Could you please look at it and see if you're doing something different? Because if you pass in the parent to the constructor, that works just as well as .add_child() or .children <<

Collaborator

mceachen commented Sep 2, 2012

OK, I figured it out. You're calling the constructor with a :parent attribute, which wasn't marked explicitly as attr_accessible. I've updated acts_as_tree.rb to set this automatically. If you upgrade to v3.4.0, things should work for you.

manutero commented Sep 2, 2012

Ok, that sounds great!

Thx for the help

2012/9/2 Matthew McEachen notifications@github.com

OK, I figured it out. You're calling the constructor with a :parent
attribute, which wasn't marked explicitly as attr_accessible. I've updated
acts_as_tree.rb to set this automatically. If you upgrade to v3.4.0, things
should work for you.


Reply to this email directly or view it on GitHubhttps://github.com/mceachen/closure_tree/issues/15#issuecomment-8219585.

Manu

Collaborator

mceachen commented Sep 2, 2012

Mantero: Don't use v3.4.0. Use v3.4.1, as Bhavin found that in v3.4.0 I had switched mysql development dependencies to incorrectly include all the database gems that' we're compatible with.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment