Agile Web Development with Rails, Edition 4

27.2 HAML 26.2 rake

27.1 Active Merchant

Determine if a credit card is valid

edit Gemfile
gem 'activemerchant', '~> 1.58'
bundle install --local
Resolving dependencies...
Using rake 12.0.0
Using qu 0.2.0 from source at `/home/rubys/git/qu-rails`
Using i18n 0.8.4
Using minitest 5.3.3
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubis 2.7.0
Using mini_portile2 2.1.0
Using rack 1.6.8
Using thor 0.19.4
Using mime-types-data 3.2016.0521
Using arel 6.0.4
Using bundler 1.15.1
Using concurrent-ruby 1.0.5
Using sqlite3 1.3.13
Using mysql2 0.4.6
Using sass 3.4.24
Using tilt 2.0.7
Using execjs 2.7.0
Using coffee-script-source 1.12.2
Using turbolinks-source 5.0.3
Using multi_json 1.12.1
Using json 1.8.6
Using rdoc 4.3.0
Using bcrypt 3.1.11
Using net-ssh 4.1.0
Using byebug 9.0.6
Using debug_inspector 0.0.3
Using i18n-js 3.0.0
Using tzinfo 1.2.3
Using nokogiri 1.7.2
Using rack-test 0.6.3
Using mime-types 3.1
Using sprockets 3.7.1
Using uglifier 3.2.0
Using coffee-script 2.4.1
Using turbolinks 5.0.1
Using sdoc 0.4.2
Using net-scp 1.2.1
Using binding_of_caller 0.7.2
Using activesupport 4.2.8 from source at `/home/rubys/git/rails`
Using loofah 2.0.3
Using mail 2.6.5
Using sshkit 1.13.1
Using rails-deprecated_sanitizer 1.0.3
Using globalid 0.4.0
Using activemodel 4.2.8 from source at `/home/rubys/git/rails`
Using jbuilder 2.6.4
Using spring 2.0.2
Using activemerchant 1.66.0
Using rails-html-sanitizer 1.0.3
Using airbrussh 1.2.0
Using rails-dom-testing 1.0.8
Using activejob 4.2.8 from source at `/home/rubys/git/rails`
Using activerecord 4.2.8 from source at `/home/rubys/git/rails`
Using capistrano 3.8.1
Using actionview 4.2.8 from source at `/home/rubys/git/rails`
Using capistrano-bundler 1.2.0
Using capistrano-rvm 0.1.2
Using capistrano-passenger 0.2.0
Using actionpack 4.2.8 from source at `/home/rubys/git/rails`
Using capistrano-rails 1.2.3
Using railties 4.2.8 from source at `/home/rubys/git/rails`
Using actionmailer 4.2.8 from source at `/home/rubys/git/rails`
Using sprockets-rails 3.2.0
Using qu-rails 0.2.0 from source at `/home/rubys/git/qu-rails`
Using coffee-rails 4.1.1
Using jquery-rails 4.3.1
Using jquery-ui-rails 6.0.1
Using rails 4.2.8 from source at `/home/rubys/git/rails`
Using sass-rails 5.0.6
Using web-console 2.3.0
Bundle complete! 22 Gemfile dependencies, 72 gems now installed.
Use `bundle info [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.2.6/gems/activemerchant-1.66.0/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

27.2 HAML 26.2 rake