Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible missing results #15

Closed
manuartero opened this issue Aug 24, 2012 · 7 comments
Closed

Possible missing results #15

manuartero opened this issue Aug 24, 2012 · 7 comments

Comments

@manuartero
Copy link

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

@mceachen
Copy link
Collaborator

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
Copy link
Collaborator

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

@manuartero
Copy link
Author

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 []

@mceachen
Copy link
Collaborator

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 <<

@mceachen
Copy link
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.

@manuartero
Copy link
Author

Ok, that sounds great!

Thx for the help

2012/9/2 Matthew McEachen [email protected]

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//issues/15#issuecomment-8219585.

Manu

@mceachen
Copy link
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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants