Commit 2abf5586f898328c02498e90db24a9e2e7cdb6c0
1 parent
65ea86e7
Exists in
master
and in
29 other branches
Refactoring extra fields validation for organizations
Showing
3 changed files
with
10 additions
and
20 deletions
Show diff stats
app/models/community.rb
... | ... | @@ -50,16 +50,6 @@ class Community < Organization |
50 | 50 | super + FIELDS |
51 | 51 | end |
52 | 52 | |
53 | - validate :presence_of_required_fieds, :unless => :is_template | |
54 | - | |
55 | - def presence_of_required_fieds | |
56 | - self.required_fields.each do |field| | |
57 | - if self.send(field).blank? | |
58 | - self.errors.add_on_blank(field) | |
59 | - end | |
60 | - end | |
61 | - end | |
62 | - | |
63 | 53 | def active_fields |
64 | 54 | environment ? environment.active_community_fields : [] |
65 | 55 | end | ... | ... |
app/models/enterprise.rb
... | ... | @@ -59,16 +59,6 @@ class Enterprise < Organization |
59 | 59 | super + FIELDS |
60 | 60 | end |
61 | 61 | |
62 | - validate :presence_of_required_fieds, :unless => :is_template | |
63 | - | |
64 | - def presence_of_required_fieds | |
65 | - self.required_fields.each do |field| | |
66 | - if self.send(field).blank? | |
67 | - self.errors.add_on_blank(field) | |
68 | - end | |
69 | - end | |
70 | - end | |
71 | - | |
72 | 62 | def active_fields |
73 | 63 | environment ? environment.active_enterprise_fields : [] |
74 | 64 | end | ... | ... |
app/models/organization.rb
... | ... | @@ -30,6 +30,16 @@ class Organization < Profile |
30 | 30 | |
31 | 31 | scope :more_popular, :order => 'members_count DESC' |
32 | 32 | |
33 | + validate :presence_of_required_fieds, :unless => :is_template | |
34 | + | |
35 | + def presence_of_required_fieds | |
36 | + self.required_fields.each do |field| | |
37 | + if self.send(field).blank? | |
38 | + self.errors.add_on_blank(field) | |
39 | + end | |
40 | + end | |
41 | + end | |
42 | + | |
33 | 43 | def validation_methodology |
34 | 44 | self.validation_info ? self.validation_info.validation_methodology : nil |
35 | 45 | end | ... | ... |