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 8378527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:56:59+00:00 2026-06-09T15:56:59+00:00

I have a multi-step Rails 3 form that I set up using this railscast:

  • 0

I have a multi-step Rails 3 form that I set up using this railscast: http://railscasts.com/episodes/217-multistep-forms, and I used another railscast to implement Stripe payment for my app: http://railscasts.com/episodes/288-billing-with-stripe

In my app, the payment form is hidden via jQuery if the amount charged to the user is 0.

$(document).ready(function() {
  var xyz = $("span#total").text();

  if (xyz == 0){
    $("div#stripefields").hide();
  };    
});

What I want to be able to do is tell my Rails app that the Stripe payment fields are not required to successfully submit the form if the amount charged to the user is 0. So, I need to modify this statement in my controller to reflect that:

elsif @video.last_step?
   @video.save if @video.all_valid? && @video.save_with_payment(@total) 

@total is the amount charged to the user, and “save_with_payment” represents the Stripe charge. What would be the best way to go about doing this? Can I add another “if” to this statement somehow?

  • 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-09T15:57:01+00:00Added an answer on June 9, 2026 at 3:57 pm

    Edit: Sorry, I made a bit of a typo.

    You need to check if the total charged is greater than 0 before paying, or allow the video to save if the total is 0.

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

    Also, in your jQuery code you’re comparing an integer to a string. You may want to:

    $(document).ready(function() {
      var xyz = parseFloat($("span#total").text());
    
      if (xyz === 0.0){
        $("div#stripefields").hide();
      }
    });
    

    Just to avoid potential inconsistencies. Comparing with == will attempt to coerce types, and you might get some odd results because of it. So by using parseFloat to turn whatever the total price is (either integer or float) into a float value and comparing against a float (0.0) we make the outcome quite clear.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a multi-step form (a wizard) that I created using this railscast: http://railscasts.com/episodes/217-multistep-forms
I have a multi-step form that I set up in rails 3 using this
I'm creating a multi-part form in the style that Ryan Bates describes here: http://railscasts.com/episodes/217-multistep-forms
I have a multi-step order form built in this manner: Step 1: Choose category
I have a large multi-step form that will insert a record into a database.
I currently have a Multi step form set up in my CodeIgniter app and
I have a multi-step form where the form on Step3 submits to Step4.php. Step4
I have got a the following problem: I have got multi-step form where in
I have a longer running multi-step process using BackgroundWorker and C#. I need to
I have a multi-step form in which i have to choose an image in

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.