Skip to content

FrozenError when calling .new on STI model with state_machine in Rails 6.1 #363

Description

@kreintjes

Calling .new on an ActiveRecord Single Table Inheritance model with a state_machine defined results in a "FrozenError: can't modify frozen Hash" since Rails 6.1.

Example, suppose we have the following model:

class Car < ApplicationRecord
  state_machine do
  end
end

which has a state and type column (the latter enabling STI) and some subclasses extending from Car. We would expect Car.new to return a new Car instance, but instead it crashes with "FrozenError: can't modify frozen Hash:".

Rails version: 6.1.4.1
Ruby version: 2.7.3
State machine version: 1.2.0

This did work in Rails 6.0 and before.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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