Skip to content

Commit

Permalink
0.0.4 only autocomplete bank name if bank code changed
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanmartin committed May 16, 2012
1 parent d259e3c commit cf3cbf2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion kontoapi-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion lib/kontoapi-rails/orm/active_record_extension.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cf3cbf2

Please sign in to comment.