Sha256: f91a3b845d02d64660885718ff3e119fc062b906f573ed3ce1a8e2df4a17a514

Contents?: true

Size: 366 Bytes

Versions: 9

Compression:

Stored size: 366 Bytes

Contents

class ForumPost < ApplicationRecord
  belongs_to :forum_thread, counter_cache: true, touch: true
  belongs_to :user
  has_many :reactions, as: :reactable

  validates :user_id, :body, presence: true

  scope :sorted, ->{ order(:created_at) }

  after_update :solve_forum_thread, if: :solved?

  def solve_forum_thread
    forum_thread.update(solved: true)
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
simple_discussion-1.2.0 app/models/forum_post.rb
simple_discussion-1.0.1 app/models/forum_post.rb
simple_discussion-1.0.0 app/models/forum_post.rb
simple_discussion-0.9.5 app/models/forum_post.rb
simple_discussion-0.9.4 app/models/forum_post.rb
simple_discussion-0.9.3 app/models/forum_post.rb
simple_discussion-0.9.2 app/models/forum_post.rb
simple_discussion-0.9.1 app/models/forum_post.rb
simple_discussion-0.9.0 app/models/forum_post.rb