forked from jah2488/mongoid-magic-counter-cache
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Joseph Chen
committed
Mar 16, 2014
1 parent
463b515
commit 16d0953
Showing
2 changed files
with
21 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class UpdateComment | ||
include Mongoid::Document | ||
include Mongoid::MagicCounterCache | ||
|
||
belongs_to :post | ||
|
||
field :remark | ||
field :is_published, type: Boolean, default: false | ||
|
||
counter_cache :post, :if => Proc.new { |act| (act.is_published) }, :if_update => Proc.new { |act| act.changes['is_published'] } | ||
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class UpdateReview | ||
include Mongoid::Document | ||
include Mongoid::MagicCounterCache | ||
|
||
embedded_in :article | ||
counter_cache :article, :if => Proc.new { |act| (act.is_published) }, :if_update => Proc.new { |act| act.changes['is_published'] } | ||
|
||
field :comment | ||
field :is_published, type: Boolean, default: false | ||
end |