active_model_serializers icon indicating copy to clipboard operation
active_model_serializers copied to clipboard

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

Open eric-norcross opened this issue 7 years ago • 3 comments

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

eric-norcross avatar Sep 07 '18 05:09 eric-norcross

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!

juliolugo96 avatar Jun 13 '20 06:06 juliolugo96

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)

bf4 avatar Jun 16 '20 04:06 bf4

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

juliolugo96 avatar Jun 16 '20 21:06 juliolugo96