#535 ✓resolved
Jeremy Nicoll

New method does not assign parent id

Reported by Jeremy Nicoll | August 20th, 2008 @ 10:48 AM

It's been about a week since I've updated DM code - I'm on deadline to finish a project! :) That being said, when you do something like this:

class User
  include DataMapper::Resource
  property  :id, Integer, :serial => true
  has n, :sit

class ParentTable
  include DataMapper::Resource
  property :id,  Integer, :serial => true
  property :user_id,  Integer, :index => true
  property :type,   String, :index => true

class Sit < ParentTable; end

And then you run the following code:

u = User.new
u_sit = u.sits.new

u_sit.user_id is nil. However, when you run u_sit = u.sits.create, u_sit.user_id is the proper number. I would expect the method new to act as the method create and populate the user_id field with the id of user.

Comments and changes to this ticket

  • Dan Kubb (dkubb)

    Dan Kubb (dkubb) December 5th, 2008 @ 04:31 AM

    • State changed from “new” to “resolved”
    • Assigned user cleared.

    I can confirm this is no longer the case on dkubb/dm-core, which will be merged into the mainline soon.

    Marking this as resolved.

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