Permalink
Browse files

Validation: Hard coded english error message removed, using Rails def…

…ault is better for I18n.
  • Loading branch information...
1 parent 55acd18 commit 3d024436737e67c08206f3bff908963a60fce50a @ledermann ledermann committed with Oct 10, 2009
Showing with 2 additions and 3 deletions.
  1. +1 −2 lib/enumlogic.rb
  2. +1 −1 spec/enumlogic_spec.rb
View
@@ -30,7 +30,6 @@ def enum(field, values, options = {})
values_array = values.is_a?(Hash) ? values.keys : values
- message = options[:message] || "#{field} is not included in the list"
constant_name = options[:constant] || field.to_s.pluralize.upcase
const_set constant_name, values_array unless const_defined?(constant_name)
@@ -58,7 +57,7 @@ def enum(field, values, options = {})
end
end
- validates_inclusion_of field, :in => values_array, :message => message, :allow_nil => options[:allow_nil]
+ validates_inclusion_of field, :in => values_array, :message => options[:message], :allow_nil => options[:allow_nil]
end
end
@@ -67,7 +67,7 @@
c = Computer.new
c.kind = "blah"
c.should_not be_valid
- c.errors[:kind].should include("kind is not included in the list")
+ c.errors[:kind].should include("is not included in the list")
end
it "should allow nil during validations" do

0 comments on commit 3d02443

Please sign in to comment.