Sha256: 447e1528d0d0b33ede67eafb21fe4dfedfda43e77384d52c9b4b5fd880896a58

Contents?: true

Size: 368 Bytes

Versions: 2

Compression:

Stored size: 368 Bytes

Contents

# coding: utf-8

class PostType < ActiveRecord::Base
  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

2 entries across 2 versions & 1 rubygems

Version Path
publify_core-9.0.1 app/models/post_type.rb
publify_core-9.0.0 app/models/post_type.rb