Sha256: da923d1d032121009c62bffb0f871f5040f822c0afba469128c557b10a25a766
Contents?: true
Size: 741 Bytes
Versions: 4
Compression:
Stored size: 741 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) new_discussion_for(user, discussion, organization).tap &:save! end def submission_for(_) nil end def try_solve_discussions(user) discussions.where(initiator: user).map(&:try_solve!) end def new_discussion_for(user, discussion_h = {}, organization = Organization.current) discussion_h.merge!(initiator_id: user.id, organization: organization) discussion_h.merge!(submission: submission_for(user)) if submission_for(user).present? discussions.new discussion_h end end
Version data entries
4 entries across 4 versions & 2 rubygems