Skip to content

Commit

Permalink
replace errors.add_to_base by errors[:base]
Browse files Browse the repository at this point in the history
  • Loading branch information
quyen committed May 13, 2013
1 parent 505c71d commit 19606e3
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions lib/app/models/annotation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def check_value
attr_name = self.attribute_name.downcase
if Annotations::Config::valid_value_types.has_key?(attr_name) &&
!([ Annotations::Config::valid_value_types[attr_name] ].flatten.include?(self.value.class.name))
self.errors.add_to_base("Annotation value is of an invalid type for attribute name: '#{attr_name}'. Provided value is a #{self.value.class.name}.")
self.errors[:base] << "Annotation value is of an invalid type for attribute name: '#{attr_name}'. Provided value is a #{self.value.class.name}."
ok = false
end
end
Expand All @@ -321,7 +321,7 @@ def check_duplicate
return true
else
if self.value.class.has_duplicate_annotation?(self)
self.errors.add_to_base("This annotation already exists and is not allowed to be created again.")
self.errors[:base] << "This annotation already exists and is not allowed to be created again."
return false
else
return true
Expand All @@ -344,7 +344,7 @@ def check_limit_per_source
anns = found_annotatable.annotations_with_attribute_and_by_source(attr_name, self.source)

if anns.length >= max
self.errors.add_to_base("The limit has been reached for annotations with this attribute and by this source.")
self.errors[:base] << "The limit has been reached for annotations with this attribute and by this source."
return false
else
return true
Expand All @@ -370,14 +370,14 @@ def check_content_restrictions
if options[:in].map{|s| s.downcase}.include?(content_to_check.downcase)
return true
else
self.errors.add_to_base(options[:error_message])
self.errors[:base] << (options[:error_message])
return false
end
else
if options[:in].include?(content_to_check)
return true
else
self.errors.add_to_base(options[:error_message])
self.errors[:base] << (options[:error_message])
return false
end
end
Expand All @@ -388,14 +388,14 @@ def check_content_restrictions
if options[:in] === 0
return true
else
self.errors.add_to_base(options[:error_message])
self.errors[:base] << (options[:error_message])
return false
end
else
if options[:in] === content_to_check.to_i
return true
else
self.errors.add_to_base(options[:error_message])
self.errors[:base] << (options[:error_message])
return false
end
end
Expand All @@ -410,4 +410,4 @@ def check_content_restrictions
end

# ===========
end
end

0 comments on commit 19606e3

Please sign in to comment.