TrestleAdmin/trestle

View on GitHub
sandbox/app/models/article.rb

Summary

Maintainability
A
0 mins
Test Coverage
class Article < ApplicationRecord
  belongs_to :author, class_name: "User"

  has_and_belongs_to_many :categories

  scope :active, -> { where(active: true) }

  serialize :tags, type: Array, coder: YAML

  validates :title, presence: true

  def tags=(tags)
    super(tags.reject(&:blank?))
  end
end