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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:04:12+00:00 2026-06-02T11:04:12+00:00

im on a users profile, ie the path is… http://localhost:3000/users/2 i have a text

  • 0

im on a users profile, ie the path is…

http://localhost:3000/users/2

i have a text field so the current user (me) can send a private message to user 2 while on his profile page.

how can i retrieve the users id and pass it in a hidden field?

<div><%= f.hidden_field :????, :value => ???? %></div>

thanks. the hidden tag field is in a form. here is the form if its helpful

<%= form_for(current_user.microposts.build(params[:micropost])) do |f| %>
  <%= render 'shared/error_messages', object: f.object %>
  <div class="field">
    <%= f.text_area :content, placeholder: "Send a private message" %>
  </div>
  <div><%= f.hidden_field :private, :value => "true" %></div>

  <%= f.submit "Post", class: "btn btn-large btn-primary" %>
<% end %>

thanks again

  • 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-02T11:04:14+00:00Added an answer on June 2, 2026 at 11:04 am

    I would try having nested routes, e.g.

    resources :users do
      resources :microposts
    end
    

    and then use

    <%= form_for([current_user, @micropost])  do |f| %>
    

    I try to avoid a hidden fields generally in rails, it usually means I’ve missed a convention.

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

Sidebar

Related Questions

I have edited /etc/profile but the path only gets changed for normal users whereas
I have an and users can login and view their own profile with a
i have a user profile in php and i want to give users the
I have a profile weblog that contains all our users details (fields seperate from
I have a form that allows a user to update their profile information, but
I have two forms in one view updating the User Profile. One Form is
I have a problem where on each users profile they have an edit button
In my app, users have messages. resources :users do resources :messages end Users can
If I had a user resource, I might have a page like /users/1. What
with Rails there is the path, edit_user_registration_path to allow users to edit their profile.

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.