Sha256: d50cf2c7c04dbf2439c1a9ea97bb5c9c7c7f5c989671af134b5bda3c8f74a98e
Contents?: true
Size: 826 Bytes
Versions: 3
Compression:
Stored size: 826 Bytes
Contents
module TheCommentsUser extend ActiveSupport::Concern included do has_many :posted_comments, class_name: :Comment, foreign_key: :user_id has_many :comcoms, class_name: :Comment, foreign_key: :holder_id end def my_comments posted_comments.with_state([:draft,:published]) end def recalculate_my_comments_counter! self.my_comments_count = my_comments.count save end def recalculate_comcoms_counters! self.draft_comcoms_count = comcoms.with_state(:draft).count self.published_comcoms_count = comcoms.with_state(:published).count self.deleted_comcoms_count = comcoms.with_state(:deleted).count save end def comments_sum published_comments_count + draft_comments_count end def comcoms_sum published_comcoms_count + draft_comcoms_count end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
the_comments-1.1.0 | app/models/concerns/the_comments_user.rb |
the_comments-1.0.0 | app/models/concerns/the_comments_user.rb |
the_comments-0.9.9 | app/models/concerns/the_comments_user.rb |