Skip to content
  • Jean Boussier's avatar
    a0993f81
    Define missing attribute methods from `method_missing` · a0993f81
    Jean Boussier authored
    Ref: https://github.com/mastodon/mastodon/issues/27622
    
    If applications don't eager load and use the old Rails 6.1 Marshal
    format, they can load Active Record instances from caches without
    calling `init_internals` hence attribute methods and aliases are
    nnot defined yet, leading to `NoMethodError`
    
    Initially I was hopping to fully get rid of the `define_attribute_methods`
    call in `init_internals` in favor of this new method missing, as it would
    remove work from the happy path, unfortunately that isn't possible
    because if a generated method overrides a default method inherited from
    object, `method_missing` won't be called. e.g. `Kernel#format`
    
    We may want to get rid of this extra code once we remove support
    for the 6.1 marshal format.
    a0993f81
    Define missing attribute methods from `method_missing`
    Jean Boussier authored
    Ref: https://github.com/mastodon/mastodon/issues/27622
    
    If applications don't eager load and use the old Rails 6.1 Marshal
    format, they can load Active Record instances from caches without
    calling `init_internals` hence attribute methods and aliases are
    nnot defined yet, leading to `NoMethodError`
    
    Initially I was hopping to fully get rid of the `define_attribute_methods`
    call in `init_internals` in favor of this new method missing, as it would
    remove work from the happy path, unfortunately that isn't possible
    because if a generated method overrides a default method inherited from
    object, `method_missing` won't be called. e.g. `Kernel#format`
    
    We may want to get rid of this extra code once we remove support
    for the 6.1 marshal format.
Loading