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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:46:40+00:00 2026-06-10T05:46:40+00:00

I am building a form that interacts with third party API via JSON. My

  • 0

I am building a form that interacts with third party API via JSON. My goal is to be able to both create a JSON call based on the values input into the form. If the JSON response returns an error, I would like to have the form_fields maintain the values used to generate the response.

How should I go about building the form and binding the JSON fields to the form?

When tied to a model i’d usually have something like:

<%= form_for @person do |f| %>
  <%= text_field_with_label f, :first_name %>
<% end %>

and in my controller i’d have:

def new
 @person = Person.new
end

But how would I set this up when there is no model. What would be in the new action on the controller? An empty JSON structure? How would I setup the input fields so they keep the values used to make the initial JSON call (in the case where the response takes the user back to the form when there is an error).

  • 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-10T05:46:41+00:00Added an answer on June 10, 2026 at 5:46 am

    Instead of using using form_for you’d be using form_tag and other *_tag methods. Your example above would be:

    <%= form_tag :controller => 'users', :action => 'myaction' %>
      First Name <%= text_field_tag :name, params[:name] %>
    <% end %>
    

    Which you could then handle in the controller and action of your choice. Remember you’ll need to add a custom route for your action in the routes.rb file too:

    get 'users/new'
    post 'users/myaction'
    

    The general logic for the controller action would be:

    def new
    end
    
    def myaction
      success = call_external_service_here
      if success
        redirect_to 'somewhere'
      else
        render 'new'
    end
    

    You would leave the new method blank in the controller. The second argument to the text_field_tag provides the value for the field, which in the new action will be blank, but the value will be inserted when the form page is rendered if the external service call results in failure.

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

Sidebar

Related Questions

I'm building a rails app that interacts with a 3rd party API When a
I'm building a form in Drupal that needs to submit to a 3rd party
So, I'm building a form that my users can customize based on their needs,
I'm building a contact form that appears in a jQuery popup box. When you
I'm building a Windows Form that includes a combo box control, and I wanted
I'm currently building a web form using APEX that is losely modelled after a
I am building a C# windows form app that pings multiple computers by name,
I'm building a login form composite component. The page that uses it will pass
Right now I'm building a simple form and I'm designing it so that if
I'm building a desktop (thick) Infopath 2010 form with code-behinds that need to set

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.