Sha256: 570eaf61024d3711ab38f7aa400f698bf143dfe7b599c6e6ff1efc59106967d4
Contents?: true
Size: 572 Bytes
Versions: 27
Compression:
Stored size: 572 Bytes
Contents
module WithDiscussions extend ActiveSupport::Concern included do has_many :discussions, as: :item, dependent: :delete_all end def discuss!(user, discussion) discussion.merge!(initiator_id: user.id) 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
27 entries across 27 versions & 2 rubygems