ActiveRecordBetterDependentErrorMessages

Short description and motivation.

Usage

How to use my plugin.

Installation

Add this line to your application's Gemfile:

gem "active_record_better_dependent_error_messages"

And then execute:

$ bundle

Or install it yourself as:

$ gem install active_record_better_dependent_error_messages

Include it in the models where you want it to inspect the relationships upon destroy like this:

class MyModel < ApplicationRecord
  include ActiveRecordBetterDependentErrorMessages::DestroyModule
end

You can add a custom error message like this:

en:
  activerecord:
    errors:
      models:
        user:
          attributes:
            base:
              cannot_delete_because_of_restriction: Cannot delete because the user has dependent %{association_name}

Contributing

Contribution directions go here.

License

The gem is available as open source under the terms of the MIT License.