Sha256: c357f5c08adefe9fd8eecf9adb129b1183ec205395a8dbd563567c2e0ec96364

Contents?: true

Size: 458 Bytes

Versions: 2

Compression:

Stored size: 458 Bytes

Contents

module Emotions
  class Emotion < ActiveRecord::Base
    self.table_name = 'emotions'

    # Validations
    validates :emotional, presence: true
    validates :emotive, presence: true
    validates_each :emotion do |record, attr, value|
      record.errors.add attr, 'invalid' unless Emotions.emotions.include?(value.try(:to_sym))
    end

    # Associations
    belongs_to :emotional, polymorphic: true
    belongs_to :emotive, polymorphic: true
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
emotions-0.1.1 lib/emotions/emotion.rb
emotions-0.1 lib/emotions/emotion.rb