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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:33:38+00:00 2026-05-12T23:33:38+00:00

I’m attempting to pass variables between forms and unfortunately i’m not managing in my

  • 0

I’m attempting to pass variables between forms and unfortunately i’m not managing

in my index.html.erb, i have a text field named SearchInput and i would like to pass this variable to the next form search.html.erb so that i may populate some data accordingly. How may i go about this please?

In my index.html.erb i have the following
<% form_tag (:action => 'search') do %>

I’m really clueless on how to go about on this please, any tips would be really appreciated

  • 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-12T23:33:38+00:00Added an answer on May 12, 2026 at 11:33 pm

    It sounds like you could benefit from reading up on the interactions between Model, View and Controller in a MVC framework like Rails. I suggest the official Getting Started Guide

    Here’s the relevant details as it relates to your question:

    When receiving a HTTP request Rails will route the request to a controller action based on the url path. The controller than builds the appropriate response by evaluating view templates in the context of the request. The standard flow in Rails is the controller will extract information from the params hash to query the database for the information required to construct the view. Instance values set in the controller (variables with names starting with ‘@’) will be available to the views rendered by this controller during this action.

    Forms in general, direct the client’s web browser to send a POST request to the specified url when the submit button is clicked. This request contains the form’s fields and their values as data in the header.

    Rails interprets the form data and any other parameters in the params hash. Which you can access in the controller or view of any action. The generally accepted place to access the params hash is in the controller.

    Lets walk through the process of what’s actually happening. The following is in terms of running a server in development assuming we’re talking about a controller for products, and you’ve set up routes correctly.

    1. User enters http://localhost:3000/products into their address bar to initiate a GET request.

    2. Rails routes this request to the index action of products controller.

    3. Rails will execute ProductsController#index (the index method located in app/controllers/products_controller.rb)

    4. Unless you explicitly render or redirect the request, Rails will render the products/index template (app/views/products/index.html.erb) which contains a small form that submits to the search action of ProductsController. Form code will look like this:

      <% form_tag(:action => 'search') do %>
        <%= text_field_tag "SearchInput" %>
        <%= submit_tag %>
      <% end %>
      
    5. User fills in the SearchInput field and submits the form as a POST request to http://localhost:3000/products/search

    6. Rails routes this request to the search action of the products controller.

    7. Rails executes ProductsController#search, the params hash contains the value the user entered into the SearchInput field with the SearchInput key. Here’s a very simple example of using the form input to perform a search.

      def search
        @products = Product.find_by_name(params["SearchInput"])
      end
      
    8. Unless you explicitly render or redirect the request, Rails will render the products/search template (app/views/products/search.html.erb) Example search view:

      <% if @products.empty? %>
        No products found
      <% else %>
        <% @products.each do |product| %>
          <%= link_to product.name, product_url(product)%> 
          <br />
        <% end %>
      <% end %>
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a text area in my form which accepts all possible characters from
I have an MVC Razor view @{ ViewBag.Title = Index; var c = (char)146;
I have thousands of HTML files to process using Groovy/Java and I need to
I have a reasonable size flat file database of text documents mostly saved in
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a bunch of posts stored in text files formatted in yaml/textile (from
Is it possible to replace javascript w/ HTML if JavaScript is not enabled on

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.