You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The text was updated successfully, but these errors were encountered:
neohunter
changed the title
[Question[ Is there any reason to do not overwrite the relationship methods of AMS?
[Question] Is there any reason to do not overwrite the relationship methods of AMS?
May 5, 2021
There is at least one case when relationship methods are not the same - when referenced relation is not ActiveRecord relation in fact but appears to be a custom method like:
classPostSerializer < BaseSerializerhas_many:commentsdefcomments5.times.map{Comment.new}endend# .., or ..classPost < AR::Basedefcomments5.times.map{Comment.new}endend# .., or even ..classPostincludeActiveModel::Modeldefcomments5.times.map{Comment.new}endend
This way the legacy has_many call is still working but lazy_has_many will crash
I'm testing this gem, our application has tons of serializer, so I was thinking in overwrite all relationships with the
lazy_*
method.I could write a monkey path for this, to make all has_many belongs_to has_one behave as the lazy_* ones,
So instead of do:
I could keep AMS syntax:
But is there any reason to don't do that?
The text was updated successfully, but these errors were encountered: