IBAN validation and Beast
I) Short snippet
validates_each :iban do | record, attr, value | record.errors.add attr, 'IBAN is mandatory' and next if value.blank? # IBAN code should start with country code (2letters) record.errors.add attr, 'Country code is missing from the IBAN code' and next unless value.to_s =~ /^[A-Z]{2}/i iban = value.gsub(/[A-Z]/) { | p | p[0]-55 } record.errors.add attr, 'Invalid IBAN format' unless (iban[6..iban.length-1].to_s+iban[0..5].to_s).to_i % 97 == 1 end
More on IBAN numbers and validation.
II) Load Beast plugins with script/console
[aurelian@stalingrad beastapp]$ script/console Loading development environment (Rails 2.0.2) beastapp> profile = User.find(:first).profile NoMethodError: undefined method `profile' for #<User:0x32b72a0> beastapp> Dispatcher.new($stdout).prepare_application => false beastapp> profile = User.find(:first).profile => #<Profile id: 1, user_id: 4, title: "Mr.", [...]