在Spree中退款时,NoMethodError(未定义的方法`编码'对于nil:NilClass)

时间:2016-10-27 20:32:49

标签: ruby-on-rails ruby spree

尝试从Spree的管理面板退款时会引发此异常。

堆栈跟踪并没有告诉我多少:

Completed 500 Internal Server Error in 54ms (ActiveRecord: 15.4ms)

NoMethodError (undefined method `encoding' for nil:NilClass):
  appsignal (1.1.5) lib/appsignal/rack/rails_instrumentation.rb:15:in `call'


  Rendered /Users/Garrett/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_source.erb (7.9ms)
  Rendered /Users/Garrett/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (3.0ms)
  Rendered /Users/Garrett/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.8ms)
  Rendered /Users/Garrett/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/actionpack-4.2.7.1/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (119.8ms)

我正在使用自定义逻辑来创建狂欢付款,这可能会导致问题:

#...
customer = Stripe::Customer.create(
        source: params[:order][:cardToken],
        email: @order.email,
        description: params[:order][:billing_first_name]
      )

      stripe_card = customer.sources.first
      spree_card = Spree::CreditCard.create!(
        last_digits: stripe_card.last4,
        cc_type: stripe_card.brand.downcase,
        month: stripe_card.exp_month,
        year: stripe_card.exp_year,
        address_id: @order.bill_address_id,
        gateway_customer_profile_id: customer.id
      )

      @order.payments.create!(
        source: spree_card,
        amount: @order.total,
        payment_method: Spree::PaymentMethod.find_by(type: 'Spree::Gateway::StripeGateway')
      )

      charge = Stripe::Charge.create(
        amount: (@order.total.to_f*100).to_i,
        currency: 'usd',
        customer: customer.id,
        description: "Website purchase",
        metadata: {"order_number" => @order.number,
                   "customer_email" => @order.email}
      )

的Gemfile:

source "https://rubygems.org"

ruby "2.2.3"

gem "autoprefixer-rails"
gem "flutie"
gem "high_voltage"
gem "jquery-rails"
gem "appsignal"
gem "sidekiq"
gem "normalize-rails", "~> 3.0.0"
gem "pg"
gem "puma"
gem "rails", "~> 4.2.0"
gem "recipient_interceptor"
gem "sass-rails", "~> 5.0"
gem "sprockets", ">= 3.0.0"
gem "sprockets-es6"
gem "title"
gem "uglifier"
gem 'coffee-rails'
gem 'spree', '~> 3.1.0.rc1'
gem 'spree_auth_devise', '~> 3.1.0.rc1'
gem 'spree_gateway', '~> 3.1.0.rc1'
gem 'aws-sdk', '< 2.0'
gem 'activerecord-session_store'
gem 'stripe', path: '~/Desktop/Projects/stripe-ruby'
gem 'mailgun_rails'
gem 'taxjar-ruby', require: 'taxjar'
gem 'sinatra', :require => false
gem 'rack-cors', :require => 'rack/cors'
gem 'spree_mail_settings', github: 'spree-contrib/spree_mail_settings', branch: '3-1-stable'
gem 'kraken-io'

group :development do

  gem "quiet_assets"
  gem "spring"
  gem "spring-commands-rspec"
end

group :development, :test do
  gem "awesome_print"
  gem "bullet"
  gem "bundler-audit", ">= 0.5.0", require: false
  gem "dotenv-rails"
  gem "factory_girl_rails"
  gem "pry-byebug"
  gem "pry-rails"
  gem "rspec-rails", "~> 3.4.0"
end

group :development, :staging do
  gem "rack-mini-profiler", require: false
end

group :test do
  gem "capybara-webkit"
  gem "database_cleaner"
  gem "formulaic"
  gem "launchy"
  gem "shoulda-matchers"
  gem "simplecov", require: false
  gem "timecop"
  gem "webmock"
end

group :staging, :production do
  gem "rack-timeout"
end

Gemfile.lock的:

GIT
  remote: git://github.com/spree-contrib/spree_mail_settings.git
  revision: e292a7e843e80ddf0337c68ed4093c702ee60f62
  branch: 3-1-stable
  specs:
    spree_mail_settings (3.1.0)
      spree_backend (~> 3.1.0.beta)

PATH
  remote: ~/Desktop/Projects/stripe-ruby
  specs:
    stripe (1.56.0)
      rest-client (>= 1.4, < 4.0)

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.7.1)
      actionpack (= 4.2.7.1)
      actionview (= 4.2.7.1)
      activejob (= 4.2.7.1)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.7.1)
      actionview (= 4.2.7.1)
      activesupport (= 4.2.7.1)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.7.1)
      activesupport (= 4.2.7.1)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (4.2.7.1)
      activesupport (= 4.2.7.1)
      globalid (>= 0.3.0)
    activemerchant (1.49.0)
      activesupport (>= 3.2.14, < 5.0.0)
      builder (>= 2.1.2, < 4.0.0)
      i18n (>= 0.6.9)
      nokogiri (~> 1.4)
    activemodel (4.2.7.1)
      activesupport (= 4.2.7.1)
      builder (~> 3.1)
    activerecord (4.2.7.1)
      activemodel (= 4.2.7.1)
      activesupport (= 4.2.7.1)
      arel (~> 6.0)
    activerecord-session_store (1.0.0)
      actionpack (>= 4.0, < 5.1)
      activerecord (>= 4.0, < 5.1)
      multi_json (~> 1.11, >= 1.11.2)
      rack (>= 1.5.2, < 3)
      railties (>= 4.0, < 5.1)
    activesupport (4.2.7.1)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    acts_as_list (0.7.2)
      activerecord (>= 3.0)
    addressable (2.4.0)
    appsignal (1.1.5)
      rack
      thread_safe
    arel (6.0.3)
    autoprefixer-rails (6.5.1.1)
      execjs
    awesome_nested_set (3.0.3)
      activerecord (>= 4.0.0, < 5)
    awesome_print (1.6.1)
    aws-sdk (1.66.0)
      aws-sdk-v1 (= 1.66.0)
    aws-sdk-v1 (1.66.0)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
    babel-source (5.8.35)
    babel-transpiler (0.7.0)
      babel-source (>= 4.0, < 6)
      execjs (~> 2.0)
    bcrypt (3.1.11)
    bootstrap-sass (3.3.7)
      autoprefixer-rails (>= 5.2.1)
      sass (>= 3.3.4)
    builder (3.2.2)
    bullet (5.0.0)
      activesupport (>= 3.0.0)
      uniform_notifier (~> 1.9.0)
    bundler-audit (0.5.0)
      bundler (~> 1.2)
      thor (~> 0.18)
    byebug (8.2.4)
    camertron-eprun (1.1.1)
    cancancan (1.10.1)
    canonical-rails (0.0.11)
      rails (>= 3.1, < 5.0)
    capybara (2.7.0)
      addressable
      mime-types (>= 1.16)
      nokogiri (>= 1.3.3)
      rack (>= 1.0.0)
      rack-test (>= 0.5.4)
      xpath (~> 2.0)
    capybara-webkit (1.10.1)
      capybara (>= 2.3.0, < 2.8.0)
      json
    carmen (1.0.2)
      activesupport (>= 3.0.0)
    cldr-plurals-runtime-rb (1.0.1)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    coderay (1.1.1)
    coffee-rails (4.1.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.1.x)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    colorize (0.8.1)
    concurrent-ruby (1.0.2)
    connection_pool (2.2.0)
    crack (0.4.3)
      safe_yaml (~> 1.0.0)
    css_parser (1.4.6)
      addressable
    database_cleaner (1.5.3)
    deface (1.0.2)
      colorize (>= 0.5.8)
      nokogiri (~> 1.6.0)
      polyglot
      rails (>= 3.1)
    devise (3.5.9)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      responders
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    devise-encryptable (0.1.2)
      devise (>= 2.1.0)
    diff-lcs (1.2.5)
    docile (1.1.5)
    domain_name (0.5.20160615)
      unf (>= 0.0.5, < 1.0.0)
    dotenv (2.1.1)
    dotenv-rails (2.1.1)
      dotenv (= 2.1.1)
      railties (>= 4.0, < 5.1)
    erubis (2.7.0)
    execjs (2.7.0)
    factory_girl (4.7.0)
      activesupport (>= 3.0.0)
    factory_girl_rails (4.7.0)
      factory_girl (~> 4.7.0)
      railties (>= 3.0.0)
    ffaker (2.2.0)
    flutie (2.0.0)
    font-awesome-rails (4.7.0.0)
      railties (>= 3.2, < 5.1)
    formulaic (0.3.0)
      activesupport
      capybara
      i18n
    friendly_id (5.1.0)
      activerecord (>= 4.0.0)
    globalid (0.3.7)
      activesupport (>= 4.1.0)
    hashdiff (0.3.0)
    high_voltage (3.0.0)
    highline (1.6.21)
    htmlentities (4.3.4)
    http (0.9.9)
      addressable (~> 2.3)
      http-cookie (~> 1.0)
      http-form_data (~> 1.0.1)
      http_parser.rb (~> 0.6.0)
    http-cookie (1.0.2)
      domain_name (~> 0.5)
    http-form_data (1.0.1)
    http_parser.rb (0.6.0)
    httparty (0.14.0)
      multi_xml (>= 0.5.2)
    i18n (0.7.0)
    jquery-rails (4.2.1)
      rails-dom-testing (>= 1, < 3)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-ui-rails (5.0.5)
      railties (>= 3.2.16)
    json (1.8.3)
    kaminari (0.17.0)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    kraken-io (0.1.3)
      activesupport
      httparty
      json
      multipart-post
    launchy (2.4.3)
      addressable (~> 2.3)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.4)
      mime-types (>= 1.16, < 4)
    mailgun_rails (0.8.0)
      actionmailer (>= 3.2.13)
      json (>= 1.7.7)
      rest-client (>= 1.6.7)
    memoizable (0.4.2)
      thread_safe (~> 0.3, >= 0.3.1)
    method_source (0.8.2)
    mime-types (3.1)
      mime-types-data (~> 3.2015)
    mime-types-data (3.2016.0521)
    mimemagic (0.3.0)
    mini_portile2 (2.1.0)
    minitest (5.9.1)
    monetize (1.4.0)
      money (~> 6.7)
    money (6.7.1)
      i18n (>= 0.6.4, <= 0.7.0)
      sixarm_ruby_unaccent (>= 1.1.1, < 2)
    multi_json (1.12.1)
    multi_xml (0.5.5)
    multipart-post (2.0.0)
    netrc (0.11.0)
    nokogiri (1.6.8.1)
      mini_portile2 (~> 2.1.0)
    normalize-rails (3.0.3)
    orm_adapter (0.5.0)
    paperclip (4.3.7)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (= 0.3.0)
    paranoia (2.1.5)
      activerecord (~> 4.0)
    pg (0.18.4)
    polyamorous (1.3.1)
      activerecord (>= 3.0)
    polyglot (0.3.5)
    premailer (1.8.7)
      css_parser (>= 1.4.5)
      htmlentities (>= 4.0.0)
    premailer-rails (1.9.4)
      actionmailer (>= 3, < 6)
      premailer (~> 1.7, >= 1.7.9)
    pry (0.10.3)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
    pry-byebug (3.3.0)
      byebug (~> 8.0)
      pry (~> 0.10)
    pry-rails (0.3.4)
      pry (>= 0.9.10)
    puma (3.4.0)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rabl (0.12.0)
      activesupport (>= 2.3.14)
    rack (1.6.4)
    rack-cors (0.4.0)
    rack-mini-profiler (0.9.9.2)
      rack (>= 1.2.0)
    rack-protection (1.5.3)
      rack
    rack-test (0.6.3)
      rack (>= 1.0)
    rack-timeout (0.4.2)
    rails (4.2.7.1)
      actionmailer (= 4.2.7.1)
      actionpack (= 4.2.7.1)
      actionview (= 4.2.7.1)
      activejob (= 4.2.7.1)
      activemodel (= 4.2.7.1)
      activerecord (= 4.2.7.1)
      activesupport (= 4.2.7.1)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.7.1)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.3)
      loofah (~> 2.0)
    railties (4.2.7.1)
      actionpack (= 4.2.7.1)
      activesupport (= 4.2.7.1)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (11.3.0)
    ransack (1.4.1)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.1)
    recipient_interceptor (0.1.2)
      mail
    redis (3.3.0)
    responders (2.3.0)
      railties (>= 4.2.0, < 5.1)
    rest-client (2.0.0)
      http-cookie (>= 1.0.2, < 2.0)
      mime-types (>= 1.16, < 4.0)
      netrc (~> 0.8)
    rspec-core (3.4.4)
      rspec-support (~> 3.4.0)
    rspec-expectations (3.4.0)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.4.0)
    rspec-mocks (3.4.1)
      diff-lcs (>= 1.2.0, < 2.0)
      rspec-support (~> 3.4.0)
    rspec-rails (3.4.2)
      actionpack (>= 3.0, < 4.3)
      activesupport (>= 3.0, < 4.3)
      railties (>= 3.0, < 4.3)
      rspec-core (~> 3.4.0)
      rspec-expectations (~> 3.4.0)
      rspec-mocks (~> 3.4.0)
      rspec-support (~> 3.4.0)
    rspec-support (3.4.1)
    safe_yaml (1.0.4)
    sass (3.4.22)
    sass-rails (5.0.4)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (>= 1.1, < 3)
    select2-rails (3.5.9.1)
      thor (~> 0.14)
    shoulda-matchers (3.1.1)
      activesupport (>= 4.0.0)
    sidekiq (4.1.1)
      concurrent-ruby (~> 1.0)
      connection_pool (~> 2.2, >= 2.2.0)
      redis (~> 3.2, >= 3.2.1)
    simplecov (0.11.2)
      docile (~> 1.1.0)
      json (~> 1.8)
      simplecov-html (~> 0.10.0)
    simplecov-html (0.10.0)
    sinatra (1.4.7)
      rack (~> 1.5)
      rack-protection (~> 1.4)
      tilt (>= 1.3, < 3)
    sixarm_ruby_unaccent (1.1.1)
    slop (3.6.0)
    spree (3.1.1)
      spree_api (= 3.1.1)
      spree_backend (= 3.1.1)
      spree_cmd (= 3.1.1)
      spree_core (= 3.1.1)
      spree_frontend (= 3.1.1)
      spree_sample (= 3.1.1)
    spree_api (3.1.1)
      rabl (~> 0.12.0)
      spree_core (= 3.1.1)
      versioncake (~> 2.3.1)
    spree_auth_devise (3.1.0)
      devise (~> 3.5.4)
      devise-encryptable (= 0.1.2)
      spree_core (~> 3.1.0.beta)
    spree_backend (3.1.1)
      bootstrap-sass (~> 3.3)
      jquery-rails (~> 4.1)
      jquery-ui-rails (~> 5.0)
      select2-rails (= 3.5.9.1)
      spree_api (= 3.1.1)
      spree_core (= 3.1.1)
    spree_cmd (3.1.1)
      thor (~> 0.14)
    spree_core (3.1.1)
      activemerchant (~> 1.49.0)
      acts_as_list (= 0.7.2)
      awesome_nested_set (~> 3.0.1)
      cancancan (~> 1.10.1)
      carmen (~> 1.0.0)
      deface (~> 1.0.0)
      ffaker (~> 2.2.0)
      font-awesome-rails (~> 4.0)
      friendly_id (~> 5.1.0)
      highline (~> 1.6.18)
      kaminari (~> 0.17)
      monetize (~> 1.1)
      paperclip (~> 4.3.0)
      paranoia (~> 2.1.0)
      premailer-rails
      rails (~> 4.2.7.1)
      ransack (~> 1.4.1)
      responders
      sprockets-rails
      state_machines-activerecord (~> 0.2)
      stringex
      truncate_html (~> 0.9.3)
      twitter_cldr (~> 3.0)
    spree_frontend (3.1.1)
      bootstrap-sass (>= 3.3.5.1, < 3.4)
      canonical-rails (~> 0.0.4)
      jquery-rails (~> 4.1)
      spree_api (= 3.1.1)
      spree_core (= 3.1.1)
    spree_gateway (3.1.0)
      spree_core (~> 3.1.0.beta)
    spree_sample (3.1.1)
      spree_core (= 3.1.1)
    spring (1.7.1)
    spring-commands-rspec (1.0.4)
      spring (>= 0.9.1)
    sprockets (3.7.0)
      concurrent-ruby (~> 1.0)
      rack (> 1, < 3)
    sprockets-es6 (0.9.0)
      babel-source (>= 5.8.11)
      babel-transpiler
      sprockets (>= 3.0.0)
    sprockets-rails (3.2.0)
      actionpack (>= 4.0)
      activesupport (>= 4.0)
      sprockets (>= 3.0.0)
    state_machines (0.4.0)
    state_machines-activemodel (0.4.0)
      activemodel (>= 4.1, < 5.1)
      state_machines (>= 0.4.0)
    state_machines-activerecord (0.4.0)
      activerecord (>= 4.1, < 5.1)
      state_machines-activemodel (>= 0.3.0)
    stringex (2.6.1)
    taxjar-model_attribute (3.1.0)
    taxjar-ruby (1.3.2)
      addressable (~> 2.3)
      http (~> 0.9.4)
      memoizable (~> 0.4.0)
      taxjar-model_attribute (~> 3.1)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (2.0.2)
    timecop (0.8.1)
    title (0.0.5)
      i18n
      rails (>= 3.1)
    truncate_html (0.9.3)
    twitter_cldr (3.6.0)
      camertron-eprun
      cldr-plurals-runtime-rb (~> 1.0)
      tzinfo
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    uglifier (3.0.0)
      execjs (>= 0.3.0, < 3)
    unf (0.1.4)
      unf_ext
    unf_ext (0.0.7.2)
    uniform_notifier (1.9.0)
    versioncake (2.3.1)
      actionpack (>= 3.2)
      activesupport (>= 3.2)
      railties (>= 3.2)
      tzinfo
    warden (1.2.6)
      rack (>= 1.0)
    webmock (1.24.5)
      addressable (>= 2.3.6)
      crack (>= 0.3.2)
      hashdiff
    xpath (2.0.0)
      nokogiri (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  activerecord-session_store
  appsignal
  autoprefixer-rails
  awesome_print
  aws-sdk (< 2.0)
  bullet
  bundler-audit (>= 0.5.0)
  capybara-webkit
  coffee-rails
  database_cleaner
  dotenv-rails
  factory_girl_rails
  flutie
  formulaic
  high_voltage
  jquery-rails
  kraken-io
  launchy
  mailgun_rails
  normalize-rails (~> 3.0.0)
  pg
  pry-byebug
  pry-rails
  puma
  quiet_assets
  rack-cors
  rack-mini-profiler
  rack-timeout
  rails (~> 4.2.0)
  recipient_interceptor
  rspec-rails (~> 3.4.0)
  sass-rails (~> 5.0)
  shoulda-matchers
  sidekiq
  simplecov
  sinatra
  spree (~> 3.1.0.rc1)
  spree_auth_devise (~> 3.1.0.rc1)
  spree_gateway (~> 3.1.0.rc1)
  spree_mail_settings!
  spring
  spring-commands-rspec
  sprockets (>= 3.0.0)
  sprockets-es6
  stripe!
  taxjar-ruby
  timecop
  title
  uglifier
  webmock

RUBY VERSION
   ruby 2.2.3p173

BUNDLED WITH
   1.12.5

0 个答案:

没有答案