Agile Web Development with Rails, Edition 5

26.2 HAML 25.2 rake

26.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 concurrent-ruby 1.0.5
Using i18n 0.8.1
Using minitest 5.10.1
Using thread_safe 0.3.6
Using builder 3.2.3
Using erubi 1.6.0
Using mini_portile2 2.1.0
Using rack 2.0.1
Using nio4r 2.0.0
Using websocket-extensions 0.1.2
Using mime-types-data 3.2016.0521
Using arel 8.0.0
Using public_suffix 2.0.5
Using net-ssh 4.1.0
Using bcrypt 3.1.11
Using bundler 1.14.6
Using byebug 9.0.6
Using ffi 1.9.18
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 0.8.2
Using thor 0.19.4
Using debug_inspector 0.0.2
Using multi_json 1.12.1
Using mysql2 0.4.5
Using pg 0.19.0
Using puma 3.8.2
Using rubyzip 1.2.1
Using sass 3.4.23
Using websocket 1.2.4
Using sqlite3 1.3.13
Using turbolinks-source 5.0.0
Using tzinfo 1.2.2
Using nokogiri 1.7.1
Using rack-test 0.6.3
Using sprockets 4.0.0.beta4
Using websocket-driver 0.6.5
Using mime-types 3.1
Using addressable 2.5.0
Using net-scp 1.2.1
Using childprocess 0.6.2
Using rb-inotify 0.9.7 from source at `/home/rubys/git/rb-inotify`
Using coffee-script 2.4.1
Using uglifier 3.1.9
Using queue_classic 3.2.0.RC1 from source at `/home/rubys/git/queue_classic`
Using turbolinks 5.0.1
Using activesupport 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using loofah 2.0.3
Using xpath 2.0.0
Using mail 2.6.4
Using sshkit 1.12.0
Using selenium-webdriver 3.3.0
Using rails-dom-testing 2.0.2
Using globalid 0.3.7
Using activemerchant 1.64.0
Using activemodel 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using jbuilder 2.6.3
Using spring 2.0.1
Using rails-html-sanitizer 1.0.3
Using capybara 2.13.0
Using airbrussh 1.1.2
Using activejob 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using activerecord 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using actionview 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using capistrano 3.8.0
Using activemodel-serializers-xml 1.0.1
Using actionpack 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using capistrano-bundler 1.2.0
Using capistrano-passenger 0.2.0
Using capistrano-rvm 0.1.2
Using actioncable 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using actionmailer 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using railties 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using sprockets-rails 3.2.0
Using capistrano-rails 1.2.3
Using coffee-rails 4.2.1
Using jquery-rails 4.2.2
Using jquery-ui-rails 6.0.1
Using web-console 3.4.0 from source at `/home/rubys/git/web-console`
Using rails 5.1.0.beta1 from source at `/home/rubys/git/rails`
Using sass-rails 6.0.0.beta1 from source at `/home/rubys/git/sass-rails`
Bundle complete! 26 Gemfile dependencies, 82 gems now installed.
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.4.0/gems/activemerchant-1.64.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

26.2 HAML 25.2 rake