Skip to content

[Rails 8.0.0] Can't modify frozen Hash serialization_context ActiveModelSerializers::SerializationContext #2486

@scottohara

Description

@scottohara

Expected behavior vs actual behavior

After upgrading to Rails 8.0.0, all serializers fail when a controller calls render json: with the error:

can't modify frozen Hash: {:serialization_context=>#<ActiveModelSerializers::SerializationContext:0x000000012b99a008 @request_url="http://127.0.0.1:3000/things/1", @query_parameters={}, @url_helpers=#<Module:0x0000000128bf4ec8>, @default_url_options={}>, :namespace=>nil}

Same application/serializers works fine with Rails 7.2.1.1.

(If you believe that this issue should instead be reported to rails/rails, please feel free to close as such)

Steps to reproduce

rails _8.0.0_ new MyApp --api
bundle add active_model_serializers
rails generate scaffold Thing name:string
rake db:migrate
rails console <<< 'Thing.create!(name: "test")'
rails server
curl http://127.0.0.1:3000/things/1

Environment

ActiveModelSerializers Version (commit ref if not on tag): 0.10.14

Output of ruby -e "puts RUBY_DESCRIPTION": ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]

OS Type & Version: macOS 15.1.1

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions