The error_splitter plugin automatically splits errors entries related to multiple columns to have separate error entries, one per column. For example, a multiple column uniqueness entry:
validates_unique([:artist_id, :name])
would by default result in errors entries such as:
{[:artist_id, :name]=>'is already taken'}
This plugin transforms those errors into:
{:artist_id=>'is already taken', :name=>'is already taken'}
The main reason to split errors is if you have a list of fields that you are checking for validation errors. If you don’t split the errors, then:
errors.on(:artist_id)
would not return the uniqueness error.
Usage:
# Make all model subclass instances split errors (called before loading subclasses) Sequel::Model.plugin :error_splitter # Make the Album class split errors Album.plugin :error_splitter