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
I'm currently working through Ruby warnings in our app, and one of the
top source is from ActiveModel Serializer sub classes.
Usually they look like:
```
class SomethingSerializer < AMS
attributes :title, :body
def title # method redefinition warning
titleize
end
end
```
One solution would be to call `attributes` at the end of the method,
so that `attributes` skips defining these, but it's quite unatural.
Instead we can use the self alias trick to mark these generated
methods as OK to redefine. An alternative would be to define them
in an included module like Active Model does, but not sure if it's
worth it.
While I was at it, I improved the way these methods are generated.
-[#2471](https://github.com/rails-api/active_model_serializers/pull/2471) Generate better attribute accessors, that also don't trigger warnings when redefined. (@byroot)
0 commit comments