#399 √ resolved
Anthony Williams

Resource#reload_attributes on a new resource fails since no collection is set

Reported by Anthony Williams | June 18th, 2008 @ 02:46 PM

Resource#reload_attributes expects a collection to be available in order to reload. This doesn't work on new records, since the collection is set using #to_query, which will return nil. This causes "undefined method `reload' for nil:NilClass" when #reload_attributes calls collection.reload.

I've fixed this in my fork, and added some specs for both Resource#reload_attributes and Resource#reload. I also tweaked #reload_attributes slightly so that it doesn't reload if you don't pass in any attribute names.

http://github.com/anthonyw/dm-co...

Rather frustratingly I realised after I committed that I hadn't added a spec which shows the collection.reload problem, so I added that in a second commit, apologies:

http://github.com/anthonyw/dm-co...

Thanks.

Comments and changes to this ticket

  • Dan Kubb

    Dan Kubb June 18th, 2008 @ 04:18 PM

      • → State changed from “new” to “open”
      • → Milestone cleared.

    Sam, this looks good. Can you give Anthony (github: anthonyw) access to merge his branch into master?

  • Bernerd Schaefer

    Bernerd Schaefer July 22nd, 2008 @ 05:06 PM

      • → State changed from “open” to “resolved”
      • → Tag changed from “” to “bug dm-core patch reload spec”

    Looks like this has been merged in. Thanks a lot, Anthony.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

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

Shared Ticket Bins