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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:01:27+00:00 2026-05-26T05:01:27+00:00

I read through the techy definition of hidden_fields , but am not sure what

  • 0

I read through the techy definition of hidden_fields, but am not sure what it really does. My understanding is that it allows you to pass in an attribute for certain parameters. For example, if you have a rich join model, you can use the hidden_field to assign the user_id to the join model attribute for user. Is that correct?

If so, would it be better to do it in the form or the controller?

  • 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-26T05:01:27+00:00Added an answer on May 26, 2026 at 5:01 am

    Both of those methods are helpers to create an HTML input tag of type “hidden”, and yes, those are used to add parameters to a request (typically a form POST). Really the parameter can be any piece of information you want to send along with a request. Be careful, though, as hidden fields are easily tampered with.

    Here’s an example that will send a user id in a hidden field

    # Form
    <%= form_tag foo_path do %>
      <%= hidden_field_tag "user_id", @user.id %>
      ....
      <%= submit_tag "Click Me" %>
    <% end %>
    
    # Controller
    def foo
      # params[:user_id] is set with the value from the hidden field
      # Do useful stuff with the POST data
    end
    

    While you can pass things such as user_id’s like this, I find that the need for it is rare. If a user_id is always required for a given situation you might consider using nested routes http://guides.rubyonrails.org/routing.html#nested-resources.

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

Sidebar

Related Questions

I read through the ruby docs examples but I'm still not sure what is
I am trying to read through the dataBind documentation, but it's not all that
I read through the android doc about supporting both but what is not really
I read through several questions similar to this one before posting, but did not
I read through various threads like this one for example. But it really escapes
I read through Apple's EADemo project. I then attempted my own. But when I
I read through many of solutions of this problem already, but I still can't
I read through quite a few similar questions here on SO but none were
I read through the javadoc and couldn't find anything that resembles it.
Had a good read through similar topics but I can't quite a) find one

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.