Coffescript not firing in Rails application

51 Views Asked by At

I'm trying to integrate stripe into an existing education based rails application. Before attempting to integrate stripe, I had a form which would create an order object and persist it to the db. I'm now attempting to include a payment on this form.

I've been following Railscast 288 to try and do this.

In the tutorial, the author triggers some actions in a coffeescript file.

The coffeescript was automatically generated when I generated the controller.

I can not get anything in my coffeescript to fire. I've tried this many times over the last couple of days, and I feel like I'm missing something small.

I'm looking for suggestions/places to look, or perhaps is there some compile step I'm missing that's not listed in the video?

I will be frantically refreshing my question once it's submitted, so if any code snippets are required, please let me know and I will edit.

Thanks!

orders.coffee

jQuery ->
  Stripe.setPublishableKey('pk_test_dceOEJSyYW9EhsJOAPsmCosT')
  order.setupForm()

order =
  setupForm: ->
    $('#new_order').submit ->
      $('input[type=submit]').attr('disabled', true)
      if $('#card_number').length
        order.processCard()
        false
      else
        true

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

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

application.js

// This is a manifest file that'll be compiled into application.js, which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path.
//
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// compiled file.
//
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

Chrome developer view

0

There are 0 best solutions below