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.58'
bundle install --local
Resolving dependencies...
Using rake 11.2.1
Using i18n 0.7.0
Using minitest 4.7.5
Using multi_json 1.12.1
Using thread_safe 0.3.5
Using tzinfo 0.3.49
Using builder 3.1.4
Using erubis 2.7.0
Using rack 1.5.5
Using mime-types-data 3.2016.0521
Using mini_portile2 2.1.0
Using pkg-config 1.1.7
Using activerecord-deprecated_finders 1.0.4
Using arel 4.0.2.20140205180311 from source at `/home/rubys/git/arel`
Using bcrypt 3.1.11
Using bundler 1.12.5
Using highline 1.7.8
Using net-ssh 3.1.1
Using coffee-script-source 1.10.0
Using execjs 2.7.0
Using thor 0.19.1
Using hike 1.2.3
Using json 1.8.3
Using mysql2 0.3.21
Using tilt 1.4.1
Using sass 3.2.19
Using sqlite3 1.3.11
Using activesupport 4.0.13 from source at `/home/rubys/git/rails`
Using rack-test 0.6.3
Using mime-types 3.1
Using nokogiri 1.6.8
Using net-scp 1.2.1
Using net-sftp 2.1.2
Using net-ssh-gateway 1.2.0
Using coffee-script 2.4.1
Using uglifier 3.0.0
Using rdoc 4.2.2
Using sprockets 2.12.4
Using activemodel 4.0.13 from source at `/home/rubys/git/rails`
Using jbuilder 1.5.3
Using actionpack 4.0.13 from source at `/home/rubys/git/rails`
Using mail 2.6.4
Using activemerchant 1.59.0
Using capistrano 2.15.8
Using sdoc 0.4.1
Using activerecord 4.0.13 from source at `/home/rubys/git/rails`
Using railties 4.0.13 from source at `/home/rubys/git/rails`
Using sprockets-rails 2.3.3 from source at `/home/rubys/git/sprockets-rails`
Using actionmailer 4.0.13 from source at `/home/rubys/git/rails`
Using rvm-capistrano 1.5.6
Using coffee-rails 4.0.1
Using jquery-rails 3.1.4
Using jquery-ui-rails 5.0.5
Using sass-rails 4.0.5
Using rails 4.0.13 from source at `/home/rubys/git/rails`
Using turbolinks 2.5.3
Bundle complete! 16 Gemfile dependencies, 56 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.2.5/gems/activemerchant-1.59.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