Sha256: 415fdd927cfa49b2fa9303e87bafd6d8e099b8b0993ca1770e39dcbff7583067

Contents?: true

Size: 566 Bytes

Versions: 4

Compression:

Stored size: 566 Bytes

Contents

class Topic < ActiveRecord::Base
  validates_presence_of :author_name
  validates :title, numericality: { only_integer: true }, on: :context_test
  validates :title, uniqueness: true

  validate -> { errors.add(:title, :validate_failed) if title == 'validate_failed' }
  before_validation -> { errors.add(:title, :invalid) if title == 'invalid' }

  has_many :books, inverse_of: :topic
  belongs_to :parent, class_name: "Topic"

  composed_of :description, mapping: [%w(title title), %w(author_name author_name)], allow_nil: true, class_name: "TopicDescription"
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
activerecord-import-0.19.1 test/models/topic.rb
activerecord-import-0.19.0 test/models/topic.rb
activerecord-import-0.18.3 test/models/topic.rb
activerecord-import-0.18.2 test/models/topic.rb