Skip to content

Commit

Permalink
Voteables should destroy their votes when they are removed.
Browse files Browse the repository at this point in the history
  • Loading branch information
Brady Bouchard committed Sep 5, 2010
1 parent a516ccb commit 2475814
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/acts_as_voteable.rb
Expand Up @@ -7,7 +7,7 @@ def self.included(base)

module ClassMethods
def acts_as_voteable
has_many :votes, :as => :voteable, :dependent => :nullify
has_many :votes, :as => :voteable, :dependent => :destroy

include ThumbsUp::ActsAsVoteable::InstanceMethods
extend ThumbsUp::ActsAsVoteable::SingletonMethods
Expand Down
2 changes: 2 additions & 0 deletions lib/acts_as_voter.rb
Expand Up @@ -9,6 +9,8 @@ module ClassMethods
def acts_as_voter

# If a voting entity is deleted, keep the votes.
# If you want to nullify (and keep the votes), you'll need to remove
# the unique constraint on the [ voter, voteable ] index in the database.
# has_many :votes, :as => :voter, :dependent => :nullify
# Destroy votes when a user is deleted.
has_many :votes, :as => :voter, :dependent => :destroy
Expand Down

0 comments on commit 2475814

Please sign in to comment.