normalize_attributes icon indicating copy to clipboard operation
normalize_attributes copied to clipboard

Feature Request: Inheritance of normalized attributes

Open lasseebert opened this issue 3 years ago • 0 comments

Description

Single table inheritance models do not inherit normalized attributes. I would expect them to.

E.g.

class Animal < ActiveRecord base
  normalize :name, :downcase
end

class Cat < Animal
end

class Dog < Animal
end

cat = Cat.new(name: "KITTY")
cat.save!
cat.name
# => "KITTY"

Describe the solution

One solution could be to implement inherited on the normalized model, so that it can pass on the normalized attributes to the child class.

Alternatives you considered

My workaround is to add the normalized attributed to each child class, which is ok, but prone to errors if one of them is updated.

Additional context

If this is indeed the intended behaviour, I can take a stab at creating a PR :)

lasseebert avatar Jan 23 '23 14:01 lasseebert