33 lines
975 B
Ruby
Executable File
33 lines
975 B
Ruby
Executable File
class Particular < ActiveRecord::Base
|
|
|
|
belongs_to :owner, :polymorphic => true
|
|
validates :name, :presence => true, :if => :force_validation
|
|
validates :firstname, :presence => true, :if => :force_validation
|
|
#validates :email, :presence => true, :format => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\z/i, :if => :force_email_validation
|
|
validates :address_2, :presence => true, :if => :force_validation
|
|
validates :cp, :presence => true, :if => :force_validation
|
|
validates :city, :presence => true, :if => :force_validation
|
|
validates :country, :presence => true, :if => :force_validation
|
|
validates :tel, :presence => true, :if => :force_validation
|
|
validates :organisation, :presence => true, :if => :validate_pro
|
|
|
|
|
|
attr_accessor :validate_email#, :skip_validation
|
|
|
|
def validate_pro
|
|
true if self.force_validation and self.pro
|
|
end
|
|
|
|
|
|
|
|
def force_validation
|
|
|
|
if self.skip_validation
|
|
false
|
|
else
|
|
true
|
|
end
|
|
end
|
|
|
|
end
|