Short description and motivation.
How to use my plugin.
Add this line to your application's Gemfile:
gem "active_record_better_dependent_error_messages"And then execute:
$ bundleOr install it yourself as:
$ gem install active_record_better_dependent_error_messagesInclude it in the models where you want it to inspect the relationships upon destroy like this:
class MyModel < ApplicationRecord
include ActiveRecordBetterDependentErrorMessages::DestroyModule
endYou 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}Contribution directions go here.
The gem is available as open source under the terms of the MIT License.