strip_attributes icon indicating copy to clipboard operation
strip_attributes copied to clipboard

Consider using the Rails 7.1 normalizes API instead of before_validation callbacks

Open rmm5t opened this issue 1 year ago • 2 comments

Similar idea as #43

Investigate and perhaps consider using the new normalizes API in Rails 7.1 instead of a before_validation callback.

This would result in a major version bump for strip_attributes, but I would still like to attempt to maintain both forwards and backwards compatibility, to some extent possible.

rmm5t avatar Nov 30 '23 17:11 rmm5t

Great idea, however, normalizes only works for ActiveRecord. I think this is a major blocker, unless you want to have two different versions to maintain. One for ActiveRecord and one for ActiveModel etc.

I opened a "feature request" in the ruby on rails forum. Maybe you want to support this (with a "hear" and/or a comment) https://discuss.rubyonrails.org/t/proposal-activemodel-normalization/85405

tmaier avatar Mar 24 '24 21:03 tmaier

There would be some benefits: The normalizes API overrides the setter - in addition to a before_validation. And it applies also for where clauses.

tmaier avatar Mar 24 '24 21:03 tmaier