Sha256: 3be37841557203d27ec8f0c64d813c07506cb3e7a4b1345b8242ae1a50f2a1c3
Contents?: true
Size: 662 Bytes
Versions: 33
Compression:
Stored size: 662 Bytes
Contents
module WithDiscussions extend ActiveSupport::Concern included do has_many :discussions, as: :item, dependent: :destroy organic_on :discussions end def discuss!(user, discussion, organization = Organization.current) discussion.merge!(initiator_id: user.id, organization: organization) discussion.merge!(submission: submission_for(user)) if submission_for(user).present? created_discussion = discussions.create discussion user.subscribe_to! created_discussion created_discussion end def submission_for(_) nil end def try_solve_discussions(user) discussions.where(initiator: user).map(&:try_solve!) end end
Version data entries
33 entries across 33 versions & 2 rubygems