Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
catmando opened this issue Apr 20, 2019 · 1 comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Milestone

Comments

@catmando
Copy link
Contributor

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.

@catmando catmando added the bug Something isn't working label Apr 20, 2019
@catmando catmando added this to the alpha1.5 milestone Apr 20, 2019
catmando added a commit that referenced this issue Apr 20, 2019
@catmando
Copy link
Contributor Author

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.

catmando added a commit that referenced this issue Apr 21, 2019
@catmando catmando added ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch and removed ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch labels Apr 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working ready-to-release Internal Use Only: Has been fixed, specs passing and pushed to edge branch
Projects
None yet
Development

No branches or pull requests

1 participant