title: Rails 5 before_destroy throw(:abort)
body: <p>I'm working in a legacy Rails app that has been diligently upgraded with each major version of Rails and we're currently on rails 5.1 and I can't get a <code>before_destroy</code> to prevent the deletion if it fails a validation</p>
  
  <p>I've been reading that <code>return false</code> has been deprecated and we're all supposed to use <code>throw :abort</code> but neither are working. I'm not getting any errors, the join record just gets deleted despite the <code>throw</code></p>
  
  <p>user.rb:</p>
  
  <pre><code>class User &lt; ApplicationRecord
    has_many :permission_users
    has_many :permissions, through: :permission_users, dependent: :destroy
  end
  </code></pre>
  
  <p>join model permission_user.rb:</p>
  
  <pre><code>class PermissionUser &lt; ApplicationRecord
    belongs_to :user
    belongs_to :permission
  
    before_destroy :check_before_removing!
  
    private
  
    def check_before_removing!
      if not_valid? # condition isn't important
        errors.add :base, exception.message
        throw(:abort)
      end
    end
  end
  </code></pre>
  
  <p>my spec:</p>
  
  <pre><code>specify "cannot have their admin permissions revoked" do
    expect {
      admin.permissions.delete admin_permission
    }.to change { admin.permissions.count }.by(0)       
  end
  
  # =&gt; expected `admin.permissions.count` to have changed by 0, but was changed by -1
  </code></pre>