Sha256: f4269f1036ce38e35f014ca0a0a7a2f2cf86dc3842aaee6b66f00639300c4601
Contents?: true
Size: 534 Bytes
Versions: 2
Compression:
Stored size: 534 Bytes
Contents
module Parole module Commentable extend ActiveSupport::Concern included do # Default options for all comments associations association_options = { class_name: 'Comment', as: :commentable, dependent: :destroy } # All comments for the record has_many :comments, association_options # Role-specific comments for the record commentable_options.fetch(:roles).each do |role| has_many :"#{role}_comments", lambda { where(role: role) }, association_options end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
parole-0.1.4 | lib/parole/commentable.rb |
parole-0.1.3 | lib/parole/commentable.rb |