You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

14 lines
253 B

  1. class Topic < ApplicationRecord
  2. self.table_name = 'threads'
  3. has_many :posts, foreign_key: :thread_id, dependent: :destroy
  4. scope :active, -> { where deleted_at: nil }
  5. validates :name, presence: true
  6. def post_count
  7. posts.count
  8. end
  9. end