I have a Rails4 application that uses rails_admin gem and MySql database.
I have a User model which has_many
Jobs . Now, in rails_admin dashboard, User can be deleted normally, unless it has some Jobs. In that case foreign key fails because there is no dependent: :destroy
defined on relation. This is intended behavior.
However, instead of getting "Cannot delete or update a parent row: a foreign key constraint fails" error I would like to show a nice message: "User can not be deleted if it has jobs".
Is there an elegant way to achieve this in rails_admin
without making a custom action?