我正在尝试将条带集成到现有的基于教育的rails应用程序中 . 在尝试集成条带之前,我有一个表单可以创建一个订单对象并将其持久保存到数据库中 . 我现在正试图在此表单上包含付款 .
我一直在关注Railscast 288尝试这样做 .
在本教程中,作者在coffeescript文件中触发了一些操作 .
生成控制器时自动生成coffeescript .
我的coffeescript中没有任何东西可以解雇 . 在过去的几天里,我已经尝试了很多次,我觉得我错过了一些小事 .
我正在寻找建议/地方看,或者是否有一些编译步骤我错过了没有在视频中列出?
一旦提交,我将疯狂地刷新我的问题,因此如果需要任何代码片段,请告诉我,我将进行编辑 .
谢谢!
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 .