blob: 5e90ca9ec8f90894f38ba526af54b7cd07bb971a (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
# == Schema Information
# Schema version: 27
#
# Table name: public_bodies
#
# id :integer not null, primary key
# name :text not null
# short_name :text not null
# request_email :text not null
# complaint_email :text
# version :integer not null
# last_edit_editor :string(255) not null
# last_edit_comment :text not null
# created_at :datetime not null
# updated_at :datetime not null
#
# models/public_body.rb:
# A public body, from which information can be requested.
#
# Copyright (c) 2007 UK Citizens Online Democracy. All rights reserved.
# Email: francis@mysociety.org; WWW: http://www.mysociety.org/
#
# $Id: public_body.rb,v 1.15 2008-01-29 01:26:21 francis Exp $
class PublicBody < ActiveRecord::Base
validates_presence_of :name
validates_presence_of :short_name
validates_presence_of :request_email
has_many :info_requests
def validate
unless MySociety::Validate.is_valid_email(self.request_email)
errors.add(:request_email, "doesn't look like a valid email address")
end
if self.complaint_email != ""
unless MySociety::Validate.is_valid_email(self.complaint_email)
errors.add(:complaint_email, "doesn't look like a valid email address")
end
end
end
acts_as_versioned
self.non_versioned_columns << 'created_at' << 'updated_at'
end
|