We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
expected: no errors when serializing
actual: error when serializing
ModelSerializer.new(model).as_json(root: false)
active_model_serializers (0.10.14)
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [arm64-darwin22]
Darwin computer.dorianmarie.fr 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
Rails 7.1.2
# /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/activemodel-7.1.2/lib/active_model/attribute_methods.rb:486:in `method_missing' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/pg_search-2.3.6/lib/pg_search/model.rb:42:in `method_missing' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:398:in `read_attribute_for_serialization' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer/field.rb:25:in `value' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:341:in `block in attributes' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:338:in `each' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:338:in `each_with_object' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:338:in `attributes' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:409:in `attributes_hash' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:372:in `serializable_hash' # /Users/dorianmariefr/.asdf/installs/ruby/3.2.2/lib/ruby/gems/3.2.0/gems/active_model_serializers-0.10.14/lib/active_model/serializer.rb:381:in `as_json'
The text was updated successfully, but these errors were encountered:
I have a patch but I can't reproduce it in the tests :(
diff --git a/lib/active_model/serializer.rb b/lib/active_model/serializer.rb index 5e347790..504b92be 100644 --- a/lib/active_model/serializer.rb +++ b/lib/active_model/serializer.rb @@ -395,7 +395,7 @@ module ActiveModel if respond_to?(attr) send(attr) else - object.read_attribute_for_serialization(attr) + object.send(:read_attribute_for_serialization, attr) end end
Sorry, something went wrong.
I verified it in my app and the patch fixes the issue
+1
Is this something which changed in Rails? Or is the model not valid per linter?
No branches or pull requests
expected: no errors when serializing
actual: error when serializing
active_model_serializers (0.10.14)
ruby 3.2.2 (2023-03-30 revision e51014f9c0) +YJIT [arm64-darwin22]
Darwin computer.dorianmarie.fr 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:53:18 PST 2023; root:xnu-10002.61.3~2/RELEASE_ARM64_T6000 arm64
Rails 7.1.2
The text was updated successfully, but these errors were encountered: