Reputation: 2848
Is it possible to convert this to an inline function?
before_destroy :no_accounts_check, prepend: true
def no_accounts_check
throw(:abort) unless accounts.count.zero?
end
I tried doing this
before_destroy { throw(:abort) unless accounts.count.zero? }, prepend: true
but it's giving me a syntax error
syntax error, unexpected ',', expecting `end')
... unless accounts.count.zero? }, prepend: true
Upvotes: 1
Views: 36
Reputation: 14900
This will probably work...
before_destroy prepend: true do
throw(:abort) unless accounts.count.zero?
end
Upvotes: 1