about summary refs log tree commit diff stats
path: root/app/models/blog.rb
blob: 1ace11ba4c6a9357cfd0c968b879a15aa7d229c0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
class Blog < ApplicationRecord
  has_many :records, as: :recordable, inverse_of: :recordable

  validates :title, :body, presence: true
  validates :slug, presence: true, format: /\A[-a-z0-9]+\z/

  accepts_nested_attributes_for :records, allow_destroy: true

  def path
    "/says/#{slug}"
  end
end