mirror of
https://github.com/TracksApp/tracks.git
synced 2025-09-22 05:50:47 +02:00
Merge pull request #152 from kytrinyx/after-destroy-destroy
Rename callback for clarity
This commit is contained in:
commit
01b7f78f3c
1 changed files with 2 additions and 3 deletions
|
@ -8,12 +8,11 @@ class Tagging < ActiveRecord::Base
|
|||
belongs_to :tag
|
||||
belongs_to :taggable, :polymorphic => true, :touch => true
|
||||
|
||||
after_destroy :after_destroy
|
||||
after_destroy :delete_orphaned_tag
|
||||
|
||||
private
|
||||
|
||||
# This callback makes sure that an orphaned <tt>Tag</tt> is deleted if it no longer tags anything.
|
||||
def after_destroy
|
||||
def delete_orphaned_tag
|
||||
tag.destroy if tag and tag.taggings.count == 0
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue