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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:59:15+00:00 2026-05-27T01:59:15+00:00

I have an Issue model and a Comment model. On the issue#show view, I

  • 0

I have an Issue model and a Comment model. On the issue#show view, I have a comment form. I create the @comment for the form in the issue#show controller action, and then pass it to the comment#create controller action to actually create and save the comment to the db. However, once the @comment params are passed to the comment#create action, I no longer have the issue_id information that I need. How would I pass that information? Here are my files:

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

issue 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
  end

and the comment controller:

  def create
    @comment = Comment.new(params[:comment])
    @comment.save
    redirect_to :back
  end
  • 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-27T01:59:16+00:00Added an answer on May 27, 2026 at 1:59 am

    You just need to modify the way you create your @comment in the show action

    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 = @issue.comments.build # assigns issue_id to comment
    end
    

    Now when you render the form for @comment, the issue_id should be present in the hidden form inputs


    This is unrelated to your question, but I’m also noticing the way you’re loading @current_user_vote

    @current_user_vote = @votes.where(:user_id => current_user.id).first
    

    You should probably do this as:

    @current_user_vote = current_user.votes.first
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some action in my rails application def show @issue = Issue.find(params[:id], :include
I have a model Issue and a nested Model Relationship In the issue.rb I
I have a model Issue. Issues have Comments and Votes through join models. In
I have a comment model. I am creating a new instance of that model
I have a Blog model that has defined var $hasMany=array(Comment); How can i apply
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue that is driving me a bit nuts: Using a UserProfileManager
We have an issue using the PEAR libraries on Windows from PHP . Pear
We have an issue related to a Java application running under a (rather old)
We have an issue on our page whereby the first time a button posts

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.