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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T07:53:57+00:00 2026-06-12T07:53:57+00:00

I followed the rails tutorial by michale hartl, I then wanted to extend it,

  • 0

I followed the rails tutorial by michale hartl, I then wanted to extend it, so I attempted to integrate the thumbs_up gem. I was able to get voting working for both posts and comments, and was very proud. But then I wanted to work on my UI a little. I didn’t like that all the forms for adding a new comment was below the feed of comments attached to the post. So I thought that all i had to do was change the order of my partials

from this

<%= render partial: 'comments/comment', collection: my_item.comments, as: :comment %>
<%= render :partial => "comments/form", :locals => { :cur_post => my_item } %>

to this

<%= render :partial => "comments/form", :locals => { :cur_post => my_item } %>
<%= render partial: 'comments/comment', collection: my_item.comments, as: :comment %>

and it would work. But this was sadly not the case. When I reorder them I get this error.

No route matches {:action=>"vote_up", :controller=>"comments", :id=>#<Comment id: nil, content: nil, user_id: nil, post_id: 14, created_at: nil, updated_at: nil>}

I am able to remove either partial and everything will work, so I am unsure why having the form above the comments causes an error.

Here is a link to a gist

any help would be great.

  • 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-12T07:53:59+00:00Added an answer on June 12, 2026 at 7:53 am

    The issue is coming from this line I believe

    <%= form_for([cur_post, cur_post.comments.build]) do |f| %>
    

    When this occurs first, it builds a new Comment onto cur_post.comments. The problem occurs now, when you render “comments/comment” that newly built comment isn’t saved. Rails expects when you pass a model into a url helper like this:

    vote_up_comment_path(comment)
    

    That the object is in the db (AFAIK)

    You should be able to get around this by not building into the comments assocaition

    <%= form_for([cur_post, Comment.new]) do |f| %>
    

    otherwise, in your comments/comment you could check to see if comment.new_record? is true and deal with it accordingly.

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

Sidebar

Related Questions

I followed the Railscast to get Sunspot running and then this tutorial on enabling
I followed Hartl's Rails tutorial where he does Ajax using RJS and sending javascript
I followed http://railsontherun.com/2007/10/04/sexy-charts-in-less-than-5-minutes/ to get regular line charts working on my rails app. Now
I'm using Rails. I just installed the backbone-rails gem and followed the instructions here
I followed a tutorial for sending email in Rails, and I have this in
I've followed Rails 3.1 on Heroku Cedar tutorial, as well as another half a
I followed the Rails Tutorial on setting up automated tests with Guard and Spork
I've followed the Rails Tutorial up to the linked point. Here's the shell output:
I followed below tutorial and built one whole complete app. http://www.tonyamoyal.com/2010/07/28/rails-authentication-with-devise-and-cancan-customizing-devise-controllers/ http://www.tonyamoyal.com/2010/09/29/rails-authentication-with-devise-and-cancan-part-2-restful-resources-for-administrators/comment-page-2/#comment-879 All is
I am trying to use PDFKit using rails 3, I followed the railscast tutorial

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.