Eager loading fails if related object doesn't exist

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • 5.1.0
    • Affects Version/s: 4.0.0 final
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I have a has_and_belongs_to_many relations, let's call it :somethings.

      There is a document in which :something_ids includes some ids that no longer exist in the related model (i.e. model.somethings.count is less than model.something_ids.count).

      If I try to eager load it with Model.includes(:somethings), then it fails with undefined method `id' for nil:NilClass here

      Might be fixed with a simple nil check on doc.

            Assignee:
            Emily Stolfo (Inactive)
            Reporter:
            Marek Stanczyk
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: