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

Bug with leaf? method #66

Open
marcinwierzbicki opened this issue Sep 8, 2017 · 4 comments
Open

Bug with leaf? method #66

marcinwierzbicki opened this issue Sep 8, 2017 · 4 comments

Comments

@marcinwierzbicki
Copy link

marcinwierzbicki commented Sep 8, 2017

leaf? method given me exception:

TypeError: nil can't be coerced into Fixnum
from /usr/local/bundle/gems/activerecord-5.0.0.1/lib/active_record/associations/collection_association.rb:319:in `+'

I have the same error with this:
model.association.children.size.zero?

Can we change implementation of leaf?


method from:

def leaf?
  children.size.zero?
end

to:

def leaf?
  children.blank?
end

?

Video: https://youtu.be/hutkAa39JcU

@felixbuenemann
Copy link
Collaborator

This is strange, because children should be a has_many association, which cannot return nil.

Maybe you have a method on your model that overrides the default children association?

@marcinwierzbicki
Copy link
Author

I have not method that overrides this chilldren association. My first idea was eager loading in ActiveRecord - my video present this behavior.

@felixbuenemann
Copy link
Collaborator

felixbuenemann commented Sep 8, 2017

This sounds similar to the ActiveRecord bug described in issue rails/rails#28579.

Could you try if the bug is fixed by using rails master?

@marcinwierzbicki
Copy link
Author

Bug is fixed in rails#master

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