Sha256: 5acf8b48cade9ffeeda7fdc974a960b0a0cfc874df51e86daeeaac33d49d8abf

Contents?: true

Size: 381 Bytes

Versions: 20

Compression:

Stored size: 381 Bytes

Contents

# frozen_string_literal: true

class PostType < ApplicationRecord
  validates :name, uniqueness: true
  validates :name, presence: true
  validate :name_is_not_read
  before_save :sanitize_title

  def name_is_not_read
    errors.add(:name, I18n.t("errors.article_type_already_exist")) if name == "read"
  end

  def sanitize_title
    self.permalink = name.to_permalink
  end
end

Version data entries

20 entries across 20 versions & 2 rubygems

Version Path
HornsAndHooves-publify_core-10.5.0 app/models/post_type.rb
HornsAndHooves-publify_core-10.4.0 app/models/post_type.rb
HornsAndHooves-publify_core-10.3.0 app/models/post_type.rb
HornsAndHooves-publify_core-10.2.0 app/models/post_type.rb
HornsAndHooves-publify_core-10.1.1 app/models/post_type.rb
HornsAndHooves-publify_core-10.1.0 app/models/post_type.rb
HornsAndHooves-publify_core-10.0.3 app/models/post_type.rb
HornsAndHooves-publify_core-10.0.2 app/models/post_type.rb
HornsAndHooves-publify_core-10.0.1 app/models/post_type.rb
HornsAndHooves-publify_core-10.0.0 app/models/post_type.rb
publify_core-9.2.9 app/models/post_type.rb
publify_core-9.2.8 app/models/post_type.rb
publify_core-9.2.7 app/models/post_type.rb
publify_core-9.2.6 app/models/post_type.rb
publify_core-9.2.5 app/models/post_type.rb
publify_core-9.2.4 app/models/post_type.rb
publify_core-9.2.3 app/models/post_type.rb
publify_core-9.2.2 app/models/post_type.rb
publify_core-9.2.1 app/models/post_type.rb
publify_core-9.2.0 app/models/post_type.rb