diff --git a/lib/couchrest/model/validations/casted_model.rb b/lib/couchrest/model/validations/casted_model.rb index b4e89e6..5c29dac 100644 --- a/lib/couchrest/model/validations/casted_model.rb +++ b/lib/couchrest/model/validations/casted_model.rb @@ -6,7 +6,9 @@ module CouchRest def validate_each(document, attribute, value) values = value.is_a?(Array) ? value : [value] return if values.collect {|doc| doc.nil? || doc.valid? }.all? - document.errors.add(attribute, :invalid, :default => options[:message], :value => value) + error_options = { :value => value } + error_options[:message] = options[:message] if options[:message] + document.errors.add(attribute, :invalid, error_options) end end end diff --git a/spec/couchrest/casted_model_spec.rb b/spec/couchrest/casted_model_spec.rb index 2ec32dd..8d7b634 100644 --- a/spec/couchrest/casted_model_spec.rb +++ b/spec/couchrest/casted_model_spec.rb @@ -286,6 +286,11 @@ describe CouchRest::Model::CastedModel do @toy2.errors.should be_empty @toy3.errors.should_not be_empty end + + it "should not use dperecated ActiveModel options" do + ActiveSupport::Deprecation.should_not_receive(:warn) + @cat.should_not be_valid + end end describe "on a casted model property" do