1 class Candidate < ActiveRecord::Base
3 validates_uniqueness_of :name
6 self.name <=> other.name
13 def picture=(picture_field)
15 unless picture_field.content_type.match(/^image/)
18 self.picture_filename = base_part_of(picture_field.original_filename)
19 self.picture_type = picture_field.content_type.chomp
20 self.picture_data = picture_field.read
24 def base_part_of(filename)
25 name = File.basename(filename)
26 name.gsub(/[^\w._-]/, '')
30 !self.picture_filename.nil?