Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update other counter caches on destroy
- Loading branch information
1 parent
34c7e73
commit 66679c8
Showing
11 changed files
with
45 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,6 @@ david: | |
id: 1 | ||
bred_dogs_count: 0 | ||
trained_dogs_count: 1 | ||
joanna: | ||
id: 2 | ||
dogs_count: 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
sophie: | ||
id: 1 | ||
trainer_id: 1 | ||
dog_lover_id: 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class Dog < ActiveRecord::Base | ||
belongs_to :breeder, :class_name => "DogLover", :counter_cache => :bred_dogs_count | ||
belongs_to :trainer, :class_name => "DogLover", :counter_cache => :trained_dogs_count | ||
belongs_to :breeder, class_name: "DogLover", counter_cache: :bred_dogs_count | ||
belongs_to :trainer, class_name: "DogLover", counter_cache: :trained_dogs_count | ||
belongs_to :doglover, foreign_key: :dog_lover_id, class_name: "DogLover", counter_cache: true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class DogLover < ActiveRecord::Base | ||
has_many :trained_dogs, :class_name => "Dog", :foreign_key => :trainer_id | ||
has_many :bred_dogs, :class_name => "Dog", :foreign_key => :breeder_id | ||
has_many :trained_dogs, class_name: "Dog", foreign_key: :trainer_id, dependent: :destroy | ||
has_many :bred_dogs, class_name: "Dog", foreign_key: :breeder_id | ||
has_many :dogs | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters