diff --git a/kontoapi-rails.gemspec b/kontoapi-rails.gemspec index dff8187..5823df9 100644 --- a/kontoapi-rails.gemspec +++ b/kontoapi-rails.gemspec @@ -39,7 +39,7 @@ Gem::Specification.new do |s| s.homepage = "http://github.com/GeneralScripting/kontoapi-rails" s.licenses = ["MIT"] s.require_paths = ["lib"] - s.rubygems_version = "1.8.15" + s.rubygems_version = "1.8.23" s.summary = "A wrapper for the Konto API (https://www.kontoapi.de/) providing model validation." s.test_files = [ "spec/kontoapi-rails_spec.rb", diff --git a/lib/kontoapi-rails/orm/active_record_extension.rb b/lib/kontoapi-rails/orm/active_record_extension.rb index 1a343a1..243ba8d 100644 --- a/lib/kontoapi-rails/orm/active_record_extension.rb +++ b/lib/kontoapi-rails/orm/active_record_extension.rb @@ -27,8 +27,10 @@ def autocomplete_bank_name(options={}) define_method :autocomplete_bank_name do current_value = send(:"#{options[:bank_name_field]}") blz = send(:"#{options[:bank_code_field]}") + blz_changed = send(:"#{options[:bank_code_field]}_changed?") begin - self.send(:"#{options[:bank_name_field]}=", KontoAPI::bank_name(blz)) if (options[:always_overwrite] || current_value.blank?) && blz.present? + self.send(:"#{options[:bank_name_field]}=", KontoAPI::bank_name(blz)) if (options[:always_overwrite] || current_value.blank?) && blz_changed + return true rescue Timeout::Error => ex case options[:on_timeout] when String