1 class Candidate < ActiveRecord::Base
3 validates_presence_of :name
5 # i have to call this picture_assoc because picture= does not overload
6 # the normal association method made by has_one
7 has_one :picture_obj, :class_name => "Picture"
9 # validate uniqueness of a name *within a given election*
12 self.name <=> other.name
24 if field and field.length > 0
25 self.picture_obj = Picture.new.set_from_field(field)
26 return picture_obj.save
33 !self.picture_obj.nil?