Sha256: cfd461f4255544660a1dc5e5c8fbcb5416448cce5750be6999d0ffd8b7c5ba2e

Contents?: true

Size: 367 Bytes

Versions: 6

Compression:

Stored size: 367 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

6 entries across 6 versions & 1 rubygems

Version Path
publify_core-9.0.0.pre6 app/models/post_type.rb
publify_core-9.0.0.pre5 app/models/post_type.rb
publify_core-9.0.0.pre4 app/models/post_type.rb
publify_core-9.0.0.pre3 app/models/post_type.rb
publify_core-9.0.0.pre2 app/models/post_type.rb
publify_core-9.0.0.pre1 app/models/post_type.rb