Open
Description
I tried to use enumerize (love it!) together with the relatively new normalizes-Method from ActiveRecord. This does not work - the normalization does not happen. Pseudo example:
class MyModel < ApplicationRecord
normalizes :locale, with: ->(value) { value.downcase.strip.presence }
enumerize :locale, in: %w[de en pl]
end
MyModel.new(locale: " DE ").valid? # => false
Without enumerize, the " DE "
would be converted to de
, and thus be valid. With enumerize, this is skipped, and enumerize reports it as invalid.
My guess is that this is due to enumerize overwriting the getter and setter for the attribute here.
Rails, on the other hand, decorates the existing attribute here (not sure yet what exactly happens there).
I could try to create a minimal reproduction, but first wanted to ask if this would be out of scope anyway.
Metadata
Metadata
Assignees
Labels
No labels