Agile Web Development with Rails, Edition 4

26.2 HAML 25.2 rake

26.1 Active Merchant

Determine if a credit card is valid

edit Gemfile
gem 'activemerchant', '~> 1.31'
bundle install --local
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.3
Using thread_safe 0.3.4
Using tzinfo 1.2.2
Using activesupport 4.1.8 from source at /home/rubys/git/rails
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.8 from source at /home/rubys/git/rails
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.8 from source at /home/rubys/git/rails
Using mime-types 2.4.3
Using mail 2.6.3
Using actionmailer 4.1.8 from source at /home/rubys/git/rails
Using active_utils 2.2.3
Using mini_portile 0.6.1
Using nokogiri 1.6.4.1
Using money 6.4.0
Using offsite_payments 2.0.1
Using activemerchant 1.44.1
Using activemodel 4.1.8 from source at /home/rubys/git/rails
Using arel 5.0.1.20140414130214
Using activerecord 4.1.8 from source at /home/rubys/git/rails
Using bcrypt 3.1.9
Using bundler 1.7.6
Using highline 1.6.21
Using net-ssh 2.9.1
Using net-scp 1.2.1
Using net-sftp 2.1.2
Using net-ssh-gateway 1.2.0
Using capistrano 2.15.5
Using coffee-script-source 1.8.0
Using execjs 2.2.2
Using coffee-script 2.3.0
Using thor 0.19.1
Using railties 4.1.8 from source at /home/rubys/git/rails
Using coffee-rails 4.1.0 from source at /home/rubys/git/coffee-rails
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.2.5
Using jquery-rails 3.1.2
Using jquery-ui-rails 5.0.2
Using mysql2 0.3.17
Using tilt 1.4.1
Using sprockets 2.12.3
Using sprockets-rails 2.1.4 from source at /home/rubys/git/sprockets-rails
Using rails 4.1.8 from source at /home/rubys/git/rails
Using rdoc 4.1.2
Using rvm-capistrano 1.5.5
Using sass 3.4.8
Using sass-rails 5.0.0.beta1 from source at /home/rubys/git/sass-rails
Using sdoc 0.4.1
Using spring 1.1.3
Using sqlite3 1.3.10
Using turbolinks 2.5.2
Using uglifier 2.5.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
mkdir script
edit script/creditcard.rb
credit_card = ActiveMerchant::Billing::CreditCard.new(
  number:     '4111111111111111',
  month:      '8',
  year:       '2009',
  first_name: 'Tobias',
  last_name:  'Luetke',
  verification_value:  '123' 
)
 
puts "Is #{credit_card.number} valid?  #{credit_card.valid?}"
rails runner script/creditcard.rb
/home/rubys/.rvm/gems/ruby-2.1.2/gems/activemerchant-1.44.1/lib/active_merchant/billing/compatibility.rb:6:in `valid?': Implicit inclusion of Rails-specific functionality is deprecated. Explicitly require "active_merchant/billing/rails" if you need it.
Is 4111111111111111 valid?  false

26.2 HAML 25.2 rake