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

Embedded association not using serializer #2247 #2367

Open
jcpny1 opened this issue Dec 17, 2019 · 10 comments
Open

Embedded association not using serializer #2247 #2367

jcpny1 opened this issue Dec 17, 2019 · 10 comments

Comments

@jcpny1
Copy link

jcpny1 commented Dec 17, 2019

Issue #2247 was closed, but I'm having trouble figuring out what the resolution was.

@bf4
Copy link
Member

bf4 commented Dec 17, 2019

@jcpny1 I closed it because it was attracting off-topic conversation and was stale.

The resolution IMHO is as follows

  1. Realize that the problem is really wanting to serialize a model-association as a resource-attribute
  2. Define the problem as 'how do I serialize a model using AMS'
  3. Look up how to serialize a model using AMS and stick that in our attribute definition
  4. profit

@joemsak
Copy link

joemsak commented Dec 9, 2020

I have the exact same issue as the linked issue.

So I should do this?

attributes :child

def child
  ChildSerializer.new(object.child)
end

instead of this?

has_one :child # (also tried adding the :serializer option, didn't work)

If that's the case I'd say that defies the developer's expectation communicated by the feature

Update changing to the manual example above did work for me, but that really doesn't feel right. Not sure why I would or should use the association methods that I have serializers for. I always want the serializers used. I upgraded from 0.8 so it seems this worked as expected in 0.8?

@bf4
Copy link
Member

bf4 commented Dec 9, 2020

@joemsak unless you need to upgrade your version for some feature in 0.10 I recommend you stay on it at this point

@joemsak
Copy link

joemsak commented Dec 9, 2020

I understand your point, and I think it still would be nice to know what to expect from this feature in the latest version, or to have this issue explained/clarified better.

@bf4
Copy link
Member

bf4 commented Dec 9, 2020

@joemsak I apologize but I'm not entirely sure what you're asking. I believe your issue is the same as the one I addressed in 2019, that you want to serialize a model relation as if it were an attribute. That being the case, the resolution is the same. In addition, if 0.8 is working for you you really should not try to update to 0.10. There's no benefit. I know you'd think there would be, but there isn't.

@joemsak
Copy link

joemsak commented Dec 9, 2020 via email

@joemsak
Copy link

joemsak commented Dec 9, 2020

I'm sorry to have to say it directly but your responses in this and the closed thread aren't helpful, and in fact are a bit rude and dismissive. We want to know why the association methods don't use the serializers and how to make them do that. I asked if your first comment meant I am expected to do it the way I showed and you still won't answer me. And if that is the answer, then I'd like the association methods to be clarified because if they don't use serializers (even when passing the :serializer option) then they don't make sense to me. I'm more than happy to hear the explanation, and I'm sure I could be convinced to the reasoning if it was just clarified.

@joemsak
Copy link

joemsak commented Dec 9, 2020

Also FYI, you did understand the issue #2247 (comment) (your comment is absolutely correct here)

@bf4
Copy link
Member

bf4 commented Dec 9, 2020

Hi @joemsak
To understand my perspective, I'm trying to do the bare minimum to be responsive while also not actually working on the gem anymore. 0.8->0.9 was a rewrite with new maintainers. 0.9->0.10 was a rewrite with new maintainers. I came only into the 0.10 rewrite and it just wasn't done right and we started considering another rewrite. There are quite a few gems born out of the learnings from this gem. It's unfortunate that AMS is basically dead at this point, but that's what has happened. I'm burnt out on it but don't want to abandon it.

I don't know why a has_one :association wouldn't use a serializer. it should. Maybe it can't find one? Maybe it's the adapter you're using? I'm not sure, but 0.8 was pretty good and if your app works on that, it probably performs better than on 0.10 too. That's why the main page is no longer 0.10.

I know you're putting in time and I appreciate it. Too many people don't do that, so I want to let you know I really appreciate your engagement. I'm sorry that I'm more limited right now and not meeting your needs.

@joemsak
Copy link

joemsak commented Dec 9, 2020

@bf4 Thank you for your answer. Now it makes more sense to me. I get where you're coming from. We would love to migrate to a modern gem of course but the migration on a large legacy project will probably be hell.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants