From 0b8211f4df980f21930191312f4e0b3adf08fc52 Mon Sep 17 00:00:00 2001 From: Jan Schwenzien Date: Tue, 19 Apr 2011 17:22:43 +0200 Subject: [PATCH] added gemspec, fixed validation errors --- kontoapi-rails.gemspec | 1 + lib/kontoapi-rails/orm/mongoid_extension.rb | 1 + lib/kontoapi-rails/validators/bank_account_validator.rb | 4 ++-- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/kontoapi-rails.gemspec b/kontoapi-rails.gemspec index 161c689..1366f4f 100644 --- a/kontoapi-rails.gemspec +++ b/kontoapi-rails.gemspec @@ -26,6 +26,7 @@ Gem::Specification.new do |s| "Rakefile", "VERSION", "init.rb", + "kontoapi-rails.gemspec", "lib/kontoapi-rails.rb", "lib/kontoapi-rails/config.rb", "lib/kontoapi-rails/orm/active_record_extension.rb", diff --git a/lib/kontoapi-rails/orm/mongoid_extension.rb b/lib/kontoapi-rails/orm/mongoid_extension.rb index e69de29..262ddfb 100644 --- a/lib/kontoapi-rails/orm/mongoid_extension.rb +++ b/lib/kontoapi-rails/orm/mongoid_extension.rb @@ -0,0 +1 @@ +# not implemented yet \ No newline at end of file diff --git a/lib/kontoapi-rails/validators/bank_account_validator.rb b/lib/kontoapi-rails/validators/bank_account_validator.rb index f25227b..03c4508 100644 --- a/lib/kontoapi-rails/validators/bank_account_validator.rb +++ b/lib/kontoapi-rails/validators/bank_account_validator.rb @@ -14,11 +14,11 @@ def validate(record) record_options = options.reverse_merge(DEFAULTS) account_number = record.send(:"#{record_options[:account_number_field]}") bank_code = record.send(:"#{record_options[:bank_code_field]}") - record.errors[:"#{record_options[:account_number_field]}"] << :invalid unless KontoAPI::valid?(account_number, bank_code) + record.errors.add(:"#{record_options[:account_number_field]}", :invalid) unless KontoAPI::valid?(account_number, bank_code) rescue Timeout::Error => ex case record_options[:on_timeout] when :fail - record.errors[:"#{record_options[:account_number_field]}"] << :timeout + record.errors.add(:"#{record_options[:account_number_field]}", :timeout) when :ignore # nop when :retry