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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:30:24+00:00 2026-05-26T08:30:24+00:00

I know this question should be really simple, but for some reason thoroughly understanding

  • 0

I know this question should be really simple, but for some reason thoroughly understanding Forms has alluded me over the years.

Basically, I want to create a new ‘feedback’ – which can be thought of as similar to a Tweet.

So when you are entering the text – which can only be done when you are logged in, (i.e. current_user is set), it should automatically store the poster_id and the receiver_id.

Here is my Feedback model:

class Feedback < ActiveRecord::Base
    belongs_to :poster, :class_name => 'User'
    belongs_to :receiver, :class_name => 'User'

end
# == Schema Information
#
# Table name: feedbacks
#
#  id          :integer         not null, primary key
#  poster_id   :integer
#  receiver_id :integer
#  content     :string(255)
#  created_at  :datetime
#  updated_at  :datetime

This is my _form partial for the creation of new Feedback objects/records.

<%= form_for(@feedback) do |f| %>
  <% if @feedback.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(@feedback.errors.count, "error") %> prohibited this feedback from being saved:</h2>

      <ul>
      <% @feedback.errors.full_messages.each do |msg| %>
        <li><%= msg %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="poster_id">
    <%= f.hidden_field(:poster, current_user) %><br />
  </div>
  <div class="receiver_id">
    <%= f.hidden_field(:receiver, @user) %><br />
  </div>
  <div class="field">
    <%= f.text_field :content %>
  </div>
  <div class="actions">
    <%= f.submit %>
  </div>
<% end %>

I tried this, but the error I keep getting is:

undefined method 'merge' for nil:NilClass

I am pretty sure I am not doing this right, but just based on the API docs and the guide, I can’t quite figure out how to do it right and why.

So if you could tell me not only what the solution is, but also why that is the case, I would really appreciate it.

Thanks.

  • 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-26T08:30:24+00:00Added an answer on May 26, 2026 at 8:30 am
      <%= f.hidden_field "poster_id", :value => current_user.id %>
      <%= f.hidden_field "receiver_id", :value => @user  %>
    

    Actually, I am not really sure about @user. Maybe you want @user.id or something?

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

Sidebar

Related Questions

I know this isn't a straightforward question but I would really appreciate some feedback
This should be simple but is boggling me for some reason. I'm sure it's
I know this should be a basic question but I am hitting a brick
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
( I don't know whether should I also post this question to ServerFault, since
I don't know which title I should use for this question. I have a
this is my first question here :) I know that I should not check
This is one of those I probably should know this, but I don't questions.
I know this question isn't directly programming related, but since I want to be

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.