@@ -25,6 +25,7 class Enumeration < ActiveRecord::Base | |||||
25 | acts_as_tree :order => 'position ASC' |
|
25 | acts_as_tree :order => 'position ASC' | |
26 |
|
26 | |||
27 | before_destroy :check_integrity |
|
27 | before_destroy :check_integrity | |
|
28 | before_save :check_default | |||
28 |
|
29 | |||
29 | validates_presence_of :name |
|
30 | validates_presence_of :name | |
30 | validates_uniqueness_of :name, :scope => [:type, :project_id] |
|
31 | validates_uniqueness_of :name, :scope => [:type, :project_id] | |
@@ -51,7 +52,7 class Enumeration < ActiveRecord::Base | |||||
51 | nil |
|
52 | nil | |
52 | end |
|
53 | end | |
53 |
|
54 | |||
54 | def before_save |
|
55 | def check_default | |
55 | if is_default? && is_default_changed? |
|
56 | if is_default? && is_default_changed? | |
56 | Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type}) |
|
57 | Enumeration.update_all("is_default = #{connection.quoted_false}", {:type => type}) | |
57 | end |
|
58 | end |
General Comments 0
You need to be logged in to leave comments.
Login now