Skip to content

if both sides of relationship are new belongs_to side may not get reported back #173

Closed

Description

@catmando
class Foo 
  belongs_to :bar 
end

class Bar
  has_one :foo 
end

bar = Bar.new(foo: Foo.new)
bar.save

everything gets saved but in the return data the new instance of Foo will not be reported, and thus bar.foo will not have an id, and will look like its still "new". If you then bar.save again, another copy of Foo gets created.

Activity

  1. added this to the alpha1.5 milestone on Apr 20, 2019
  2. added a commit that references this issue on Apr 20, 2019
  3. catmando commented on Apr 20, 2019

    @catmando
    ContributorAuthor

    There are two reasons the data may not get reported:

    1. There is not policy for the Foo, so no attributes are returned.
    2. Because of the order of saves on the server, what happens is the new instances of foo and bar are created, and linked, but then bar is saved first, causing an automatic save of foo. This makes the system think foo never changed, and thus no data is reported.
  4. added
    ready-to-releaseInternal Use Only: Has been fixed, specs passing and pushed to edge branch
    and removed
    ready-to-releaseInternal Use Only: Has been fixed, specs passing and pushed to edge branch
    on Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingready-to-releaseInternal Use Only: Has been fixed, specs passing and pushed to edge branch

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions