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

  • Home
  • SEARCH
  • 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 8904947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T02:15:58+00:00 2026-06-15T02:15:58+00:00

I know I am missing something.. I don’t know how to fix it. I

  • 0

I know I am missing something.. I don’t know how to fix it.

I have a Message model which has a body attribute.

the controller is located under users/messages_controller.rb

my routes

  namespace :users do
    resources :messages
  end

which give

users_messages     GET    /users/messages(.:format)           users/messages#index
                   POST   /users/messages(.:format)           users/messages#create
new_users_message  GET    /users/messages/new(.:format)       users/messages#new
edit_users_message GET    /users/messages/:id/edit(.:format)  users/messages#edit
users_message      GET    /users/messages/:id(.:format)       users/messages#show
                   PUT    /users/messages/:id(.:format)       users/messages#update
                   DELETE /users/messages/:id(.:format)       users/messages#destroy

I created a partial which I render on users/show via

  <%= render :partial => 'users/messages/sendme' %>

_sendme.html.erb

<%= form_tag(users_messages_path) do %>
         <%= text_area_tag "Message" %>
         <%= submit_tag 'Submit' %>
<% end %>

but when I submit a message, and it goes to the create action in messages_controller I can’t pull the id of the user from which the message was sent.
The params that I get are

pry(#<Users::MessagesController>)> params
=> {"utf8"=>"Γ£ף",
 "authenticity_token"=>"IrcPBHgBp/BI...mBbOQx7gcJc5xNtAFs=",
 "Message"=>"test",
 "commit"=>"Submit",
 "action"=>"create",
 "controller"=>"users/messages"}

The URL of the users/show is http://localhost:3000/users/24
What do I need to add so I can get the user’s ID in the params?

  • 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-15T02:15:59+00:00Added an answer on June 15, 2026 at 2:15 am

    If you have the @user available in your form, create a hidden_field_tag inside it like this:

    <%= hidden_field_tag :id, @user.id %>
    

    Then, when you submit your form, the params[:id] would be populated as @user.id.

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

Sidebar

Related Questions

I have this code, I know I'm missing something but don't know what. It
I don't know if i'm being stupid and missing something obvious but: I have
I know I'm missing something small.. please help! I have a repo for my
I know I'm probably missing something easy, but I have a foreach loop and
I don't know if I'm missing something here but isn't it strange that my
I don't know if I'm missing something, or what, but I've been looking over
Don't know if I'm missing something here. I'd like to run multiple global variables
I don't know what's wrong with my syntax, but I'm missing something: $createrequest =
I don't know if I am missing something obvieouse but, I thought you can
I know I'm missing something really easy here... CarrierWave::Storage::Fog::File has a method exists ?

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.