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

The Archive Base Latest Questions

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

I have a form_for a comment. Comments belongs_to Issue. I have a comments form

  • 0

I have a form_for a comment. Comments belongs_to Issue. I have a comments form on my issue#show view, which is where my form_for is. I create the comment object @comment in my issue#show controller action. When i submit the form, it calls the comment#create controller action. However, I need a variable called :issue_id. I have issue_id in the issue#show view, and I can even set the @comment object to have issue_id. However, when it gets passed to the comments#create controller, the issue_id isn’t being passed in the params[:comment] so when the comment gets created and saved, it’s not there. Here are my files:

issue#show view:

<%= form_for @comment do |f| %>
    <%= render 'comment_fields', :f => f %>
    <%= f.submit "Submit" %>
<% end %>

issue#show controller:

  def show
    @issue = Issue.find(params[:id])
    @votes = Votership.where(:issue_id => @issue.id)
    @current_user_vote = @votes.where(:user_id => current_user.id).first
    @comment = Comment.new(:issue_id => @issue.id)
  end

and the comments#create controller where the comment gets created:

  def create
    @comment = Comment.new(params[:comment])
    @comment.user = current_user
    @comment.save
    redirect_to :back
  end

I tried adding a hidden field in the form, but it kept creating a hash of values and the key would be the issue_id but I couldn’t figure out how to set the value of the hidden field, which is weird. How do I do this correctly?

PS comments belong_to issues. issues has many comments. issues belongs_to apps. apps has many issues.

  • 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-27T02:58:01+00:00Added an answer on May 27, 2026 at 2:58 am

    I do not actually understand your complain but from what i understand you are trying to get the issue id to be saved with the comment. you should have a hidden field in your form like

    <%= f.hidden_field :issue_id %>
    

    if this is not the solution you need pls let me know so i can help again.

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

Sidebar

Related Questions

I have a comment controller that uses a form partial to add comments. Now
I have 3 models: User: has_many :comments Video: has_many :comments Comment: belongs_to :video, :user
I have a simple Comment model and controller. When I create a comment in
Currently I am have a comment which belongs to a micropost, but the issue
I have a comment form (in comments/_form.html.erb) that I use in my other controllers
I have this in one of my haml views: -form_for :news_item_comment, :url=>{:id => comment.id,
I have a html form for uploading a file, which is as follows: $uploadhtml
I have the following form for photo_album which uses the nested forms feature of
I have form with one input for email and two submit buttons to subscribe
I have this form_for: <%= form_for [post, Comment.new,], :remote => true do |f| %>

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.