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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:39:54+00:00 2026-05-21T23:39:54+00:00

I apologize for sounding daft in advance, but I recently discovered JSON in Rails

  • 0

I apologize for sounding daft in advance, but I recently discovered JSON in Rails and I’m really interested in creating a form that is broken up through several pages. The data would then be carried from page to page through a JSON object.

I’m stuck on how to properly to do that.

My first page of the form is this :

First Page

Controller:

def create
  # removed some code here for the sake of simplicity
  if @card_signup.save
    respond_to do |wants|
      wants.html {}
      wants.json { render :json => { :html => (render_to_string :partial => 'final_form')}}
    end
  else
    respond_to do |wants|
      wants.html { render :new }
      wants.json { render :json => { :errors => @card_signup.errors } }
    end
  end
end

The Javascript that handles saving the first form to this controller

$(".step_two_submit").click(function(){

  $("#new_card_signup").attr("action", function(index, action) {
    var values = [],
        getKey;

    $("#sortable").sortable('serialize').replace(/(\w+?)\[]=(\d+?)/g, function(all, key, number) {
        values.push(number);
        getKey = key;
    });

    var cardSignupGetParams = 'card_signup=' + getKey + '[' + values.join(', ') + ']';
    return action + '?' + cardSignupGetParams + "&foo[]=bar";
  });

});

Here’s the tough part! I want to make it so that I validate if this form was written correctly as usual. No problem, the form is set up to do that. But when they click next, I want them to go to a second form which is a disclaimer they have to agree to before the Object is saved.

So if they back out, or don’t approve of the disclaimer, the Object will have never been created.

To accomplish this.. I assume I need to instead of saving the object, I need to store the object in a JSON object and carry it over via AJAX to this next AJAX loaded disclaimer page.

Does anyone know how I might be able to splice that together?

Again, I apologize if this doesn’t make much sense.

  • 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-05-21T23:39:55+00:00Added an answer on May 21, 2026 at 11:39 pm

    What you really want to do is validate the object before you go to the second part of the page. If you definitely want to make a round trip to the server, you can use @card_signup.valid? instead of @card_signup.save in the controller of your “check” action, and then just hide the form elements with javascript and show your disclaimer. This way you are still checking that it would save when it’s finally submitted, but not actually saving it into the database.

    Another way to do this without javascript would be to have the first page submit to the controller action that just checked for a valid object, and go to a second page which then renders most of the form elements as hidden elements, effectively carrying the filled-in form to the second page without saving it.

    Alternately, you can do the validation on the client side as much as possible and not hit the server. See the Client Side Validations railscast for an interesting and easy-ish way to get this done.

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

Sidebar

Related Questions

I apologize if this is a really beginner question, but I have not worked
I apologize in advance for a newbie question, but why do I get Access
I apologize that this is a dumb question, but I have been pulling my
I apologize in advance for the long-winded question but I wanted to make sure
Apologize in advance for the amount of codes, but I can't find where the
apologize if there is already answer for that, but as a newbie to I'm
I apologize for such a long message in advance, but I'm trying for detail
I apologize that this isn't a question on how to use Mathematica, but rather
This is probably a really stupid newbie-sounding question to you developer type people, but
I apologize for asking such a generalized question, but it's something that can prove

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.