Skip to content
  • Vasiliy Ermolovich's avatar
    433bd599
    Raise `NoMethodError` in `ActiveModel::Type::Value#as_json` method. · 433bd599
    Vasiliy Ermolovich authored
    Right now since we have instance variable called `itself_if_serialize_cast_value_compatible`
    assigned to self when we run `as_json` we get stack too deep error because `as_json` calls
    `as_json` on every instance variable. And since `@itself_if_serialize_cast_value_compatible` references
    to `self` we run into recursion.
    
    And before that we were returning unpredictable data from `as_json` method so it's better to let it to throw
    an error and let user know that Value class is not supposed to be converted to json.
    433bd599
    Raise `NoMethodError` in `ActiveModel::Type::Value#as_json` method.
    Vasiliy Ermolovich authored
    Right now since we have instance variable called `itself_if_serialize_cast_value_compatible`
    assigned to self when we run `as_json` we get stack too deep error because `as_json` calls
    `as_json` on every instance variable. And since `@itself_if_serialize_cast_value_compatible` references
    to `self` we run into recursion.
    
    And before that we were returning unpredictable data from `as_json` method so it's better to let it to throw
    an error and let user know that Value class is not supposed to be converted to json.
Loading