错误:第17行上的解析错误:意外的'INDENT'

时间:2013-12-11 19:51:25

标签: ruby-on-rails ruby-on-rails-3.2 coffeescript stripe-payments

我想我的coffeescript存在问题。我正在关注条带计费轨道广播但是我收到以下错误:

错误:第17行的解析错误:意外的'INDENT'

我的咖啡是这个

$ ->
    $('.post').hover (event) ->
        $(this).toggleClass("hover")

  Stripe.setPublishableKey($('meta[name="stripe-key"]').attr('content'))
  payment.setupForm()

payment =
  setupForm: ->
    $('#new_payment').submit ->
      $('input[type=submit]').attr('disabled', true)
        payment.processCard()
        false

  processCard: ->
    card =
      number: $('#card_number').val()
      cvc: $('#card_code').val()
      expMonth: $('#card_month').val()
      expYear: $('#card_year').val()
    Stripe.createToken(card, payment.handleStripeResponse)

  handleStripeResponse: (status, response) ->
    if status == 200
      alert(response.id)
    else
      alert(response.error.message)

1 个答案:

答案 0 :(得分:1)

payment.setupForm中的两行有额外的缩进。

替换:

payment =
  setupForm: ->
    $('#new_payment').submit ->
      $('input[type=submit]').attr('disabled', true)
        payment.processCard() # <---------------------- Here
        false # <-------------------------------------- Here

with:

payment =
  setupForm: ->
    $('#new_payment').submit ->
      $('input[type=submit]').attr('disabled', true)
      payment.processCard()
      false