# -*- encoding : utf-8 -*- class Person < ActiveRecord::Base belongs_to :sheet #validates_presence_of :surname, :firstname has_many :people_newsgroups has_many :newsgroups, :through => :people_newsgroups #attr_accessible :newsgroup_ids, :newsletter, :surname, :firstname, :email, :phone, :job validates :surname, :presence => true validates :firstname, :presence => true validates :email, :presence => true, :if => :web? # validates :email, :format => { :with => /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/i } attr_accessor :web def web? true if self.web end def name self.firstname.to_s+" "+self.surname.to_s end end