Module: Mongoid::Commentable

Extended by:
ActiveSupport::Concern
Defined in:
lib/mongoid_socializer_actions/commentable.rb

Instance Method Summary collapse

Instance Method Details

#commentersObject

get commenters

Example:

> @photo.commenters

> [@sree, @hari]



15
16
17
18
# File 'lib/mongoid_socializer_actions/commentable.rb', line 15

def commenters
  commenter_ids = comments.distinct('commenter_id')
  User.find(commenter_ids)
end

#comments_with_eager_loaded_commenterObject

Load comments with commenter

Example:

> @photo.comments_with_eager_loaded_commenter

> [@sree, @hari]



25
26
27
# File 'lib/mongoid_socializer_actions/commentable.rb', line 25

def comments_with_eager_loaded_commenter
  comments.includes(:commenter)
end