rails-api / active_model_serializers

ActiveModel::Serializer implementation and Rails hooks
MIT License
5.33k stars 1.39k forks source link

Deprecation warning when using ActiveModel::SerializableResource.new does not specify alternative #2280

Open eric-norcross opened 6 years ago

eric-norcross commented 6 years ago

Message: NOTE: ActiveModel::SerializableResource.new is deprecated; use ActiveModelSerializers::SerializableResource. instead

Expected behavior vs actual behavior

Expected behavior: The deprecation message should Indicate what the new/replacement method is. Actual behavior: The new method is omitted

(guessing it should read: ActiveModelSerializers::SerializableResource.new)

Steps to reproduce

Call ActiveModel::SerializableResource.new

Environment

ActiveModelSerializers Version: 0.10.7

Output of ruby -e "puts RUBY_DESCRIPTION": ruby 2.5.0p0 (2017-12-25 revision 61468) [x86_64-darwin16]

OS Type & Version: MacOS 10.12.6

Integrated application and version (e.g., Rails, Grape, etc): Rails 5.1.4

juliolugo96 commented 4 years ago

Sorry for delayed response. I hope this could help someone who has this same problem.

As far as I concerned, you can use the new method , if I'm not misintrepreting what it's pointed in the docs . If you have an instance already, personally I've used initialize() method.

Hope it helps. Cheers!

bf4 commented 4 years ago

yeah, it should read ActiveModelSerializers::SerializableResource.new

@juliolugo96 new is a class method initialize is an instance method (called by the class method new on the return value of the class method allocate)

juliolugo96 commented 4 years ago

@bf4 That's right. Thanks for the clarification, I'll update my comment.