Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8399839
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T21:24:42+00:00 2026-06-09T21:24:42+00:00

I’m using Stripe to accept payments in my Rails 3 app. Stripe requires this

  • 0

I’m using Stripe to accept payments in my Rails 3 app. Stripe requires this coffeescript:

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

video =
  setupForm: ->
    $('#new_video input:submit').click ->
      $(this).addClass('wasclicked')

    $('#new_video').submit ->
      clickedBtn = $(this).find('.wasclicked')

      if clickedBtn.attr('name') != 'back_button' && $('#card_number').length
        video.processCard()
        clickedBtn.removeClass('wasclicked')
        false
      else
        true

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

  handleStripeResponse: (status, response) ->
    if status == 200
      $('#video_stripe_card_token').val(response.id)
      $('#new_video')[0].submit()
    else
      $('#stripe_error').text(response.error.message)
      $('input[type=submit]').attr('disabled', false)

In my app, if the charge to the customer is 0, then the Stripe credit card fields are hidden, and not required to successfully submit the form. This statement in my controller accounts for that:

@video.save if @video.all_valid? && ((@total > 0 && @video.save_with_payment(@total)) || @total == 0)

Here’s the problem I’m having: when the charge is 0, and payment is not required in my form, I hit the submit button to submit the form, and nothing happens. I can just click and click and there’s no response whatsoever. However, when I reload the page, then the form is successfully submitted.

I deleted the coffeescript file (above) for Stripe, and then the submit button worked in this instance. So how do I disable the coffeescript in this example? Would an “if” statement go into my controller, or the coffeescript?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T21:24:44+00:00Added an answer on June 9, 2026 at 9:24 pm

    In your submit event, returning false prevents the form from submitting. If you don’t want this behavior, return any value other than false. In this case it sounds like you just need to bypass processing all together if your charge is 0, this is what you would need:

    $('#new_video').submit ->
      clickedBtn = $(this).find('.wasclicked')
    
      if clickedBtn.attr('name') != 'back_button' && $('#card_number').length && $('#charge').val() > 0
        video.processCard()
        clickedBtn.removeClass('wasclicked')
        false
      else
        true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am using JSon response to parse title,date content and thumbnail images and place
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.