Permalink
Browse files

enable scope for all_comments when using roles

Useful when building admin panels and wish to list all comments (public/private)
  • Loading branch information...
davidcollom committed Mar 22, 2013
1 parent 2d38474 commit 7f68f2b5c2635446bc8a03ab2c45fcfee8497ae4
Showing with 1 addition and 0 deletions.
  1. +1 −0 lib/commentable_methods.rb
@@ -27,6 +27,7 @@ def acts_as_commentable(*args)
:conditions => ["role = ?", role.to_s],
:before_add => Proc.new { |x, c| c.role = role.to_s }}
end
+ has_many :all_comments, {:as => :commentable, :dependent => :destroy, class_name: "Comment"}
else
has_many :comments, {:as => :commentable, :dependent => :destroy}
end

2 comments on commit 7f68f2b

@jackdempsey

This comment has been minimized.

Show comment Hide comment
@jackdempsey

jackdempsey Mar 22, 2013

is there a reason we wouldn't want to just call it comments? (sry if obvious, been a while since i've looked at this codebase)

is there a reason we wouldn't want to just call it comments? (sry if obvious, been a while since i've looked at this codebase)

@davidcollom

This comment has been minimized.

Show comment Hide comment
@davidcollom

davidcollom Mar 22, 2013

Owner
Owner

davidcollom replied Mar 22, 2013

Please sign in to comment.