Slide 35
Slide 35 text
1 class SupportIncident
2 include ActiveModel::Validations
3 include ActiveModel::Conversion
4
5 attr_accessor :name, :email, :customer_id, :description
6 validates_presence_of :name, :email, :description
7 validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
8 validates_format_of :customer_id, :with => /\d{8}/i
9
10 def initialize(attributes = {})
11 attributes.each do |name, value|
12 send("#{name}=", value)
13 end
14 end
15
16 def persisted?
17 false
18 end
19 end
Needs to have persisted? method
return false
ActiveModel