Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-663

Doesn't save associations

    • Type: Icon: Task Task
    • Resolution: Done
    • 2.1.0
    • Affects Version/s: None
    • Component/s: None
    • Labels:

      Hi, I'm using mongoid from git, and I'm experiencing a problem that might be a bug:

      https://gist.github.com/32c74f2a8fa42b8ebc11

      ruby-1.9.2-p136 :015 > u = User.new
      => User _id: 4d4dc1214fcb061f24000003, created_at: nil, updated_at: nil, authentication_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, subdomain: nil, email: nil, nickname: nil, given_name: nil, family_name: nil, location: nil, url: nil, birthday: nil

      ruby-1.9.2-p136 :016 > u.email = 'test@example.com'
      => "test@example.com"

      ruby-1.9.2-p136 :017 > u.nickname = 'test'
      => "test"

      ruby-1.9.2-p136 :020 > u.subdomain = 'test'
      => "test"

      ruby-1.9.2-p136 :023 > authorization = Authorization.new
      => Authorization _id: 4d4dc1684fcb061f24000004, created_at: nil, updated_at: nil, provider: nil, uid: nil, token: nil, secret: nil, url: nil, user_id: nil

      ruby-1.9.2-p136 :024 > authorization.uid = '1234'
      => "1234"

      ruby-1.9.2-p136 :025 > authorization.provider = 'twitter'
      => "twitter"

      ruby-1.9.2-p136 :026 > authorization.token = '12345'
      => "12345"

      ruby-1.9.2-p136 :027 > authorization.secret = '12345abcde'
      => "12345abcde"

      ruby-1.9.2-p136 :029 > u.authorizations << authorization
      => [Authorization _id: 4d4dc1684fcb061f24000004, created_at: nil, updated_at: nil, provider: "twitter", uid: "1234", token: "12345", secret: "12345abcde", url: nil, user_id: BSON::ObjectId('4d4dc1214fcb061f24000003')]

      ruby-1.9.2-p136 :030 > u.save
      => true

      ruby-1.9.2-p136 :037 > user = User.last
      => User _id: 4d4dc1214fcb061f24000003, created_at: 2011-02-05 21:32:02 UTC, updated_at: 2011-02-05 21:32:02 UTC, authentication_token: nil, remember_token: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, subdomain: "test", email: "test@example.com", nickname: "test", given_name: nil, family_name: nil, location: nil, url: nil, birthday: nil

      ruby-1.9.2-p136 :038 > user.authorizations
      => []

      ruby-1.9.2-p136 :040 > user.valid?
      => false

      If this is not a bug, I'm definitely very lost
      What's weird is that if the association is not valid, it correctly errors out.

            Assignee:
            Unassigned Unassigned
            Reporter:
            ngw Nicholas Wieland
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: