#32 ✓resolved
Rein Henrichs

#has_many returns nil instead of []

Reported by Rein Henrichs | October 27th, 2007 @ 02:25 PM

# Project has_many sections
Project.new.sections.should == []

Comments and changes to this ticket

  • Sam Smoot

    Sam Smoot October 27th, 2007 @ 04:58 PM

    • State changed from “new” to “resolved”

    This is similar to ticket 31, and had the same cause (a misleading #inspect string).

    Added a spec just the same to ensure it was tested:

    it "should return an empty Enumerable for new objects" do
      project = Project.new
      project.sections.should be_a_kind_of(Enumerable)
      project.sections.should be_empty

    Note that the accessor for a has_many returns an instance of HasManyAssociation::Set, not a raw Array.

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket