pic_vert_app/app/models/person.rb
Nicolas Bally 429325823c suite
2019-06-02 18:48:14 +02:00

25 lines
666 B
Ruby

# -*- 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