You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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:
Without enumerize, the
" DE "
would be converted tode
, 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.
The text was updated successfully, but these errors were encountered: