Sha256: 4c2a568d5989df311382b296ec57b615c41acd33233f00b02a89662cbc4cd3c8
Contents?: true
Size: 690 Bytes
Versions: 44
Compression:
Stored size: 690 Bytes
Contents
# Participants rate their emotions a name and intensity class Emotion < ActiveRecord::Base belongs_to :creator, class_name: "Participant" has_many :emotional_ratings, dependent: :destroy validates :creator, presence: true validates :name, presence: true validates :name, uniqueness: { scope: :creator_id } before_validation :normalize_name def self.associate(participant, name) find_or_create_by( creator_id: participant.id, name: normalized_name(name) ) end private def self.normalized_name(n) n.strip.downcase end def normalize_name if name.respond_to?(:strip) self.name = self.class.normalized_name(name) end end end
Version data entries
44 entries across 44 versions & 1 rubygems