Sha256: 503267f076452d1cff090977a1ebb40f24431043dc8d78af77f567c25a707a80
Contents?: true
Size: 548 Bytes
Versions: 8
Compression:
Stored size: 548 Bytes
Contents
module WithDiscussions extend ActiveSupport::Concern included do has_many :discussions, as: :item 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
8 entries across 8 versions & 1 rubygems