RubyFlow The Ruby and Rails community linklog

How to enable reusability for ActiveRecord::Base::normalizes

This article reviews the new normalizes feature in Ruby on Rails 7.1 and shows how to increase reusability by creating normalizer modules. I also opened a feature request to add support for ActiveModel, since ActiveRecord::Normalization only supports ActiveRecord, obviously. Please show your support.

Comments

I think having all this setup is quite an overkill for what you could do with a before validation callback:

.presence&.strip

I like it. You should make a PR directly on Rails (the discussion board isn’t well monitored). Also, have you considered using with_options to reuse configuration?

Post a comment

You can use basic HTML markup (e.g. <a>) or Markdown.

As you are not logged in, you will be
directed via GitHub to signup or sign in