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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T16:34:04+00:00 2026-06-11T16:34:04+00:00

I am getting the below error when running a Rail App. I believe it

  • 0

I am getting the below error when running a Rail App. I believe it is being caused because Rails is showing comments from 0, instead of 1. The record 0 does not exist. All I want to do is make it possible to edit each comment.

I think the error is how I am creating the links to nested resources (ie linking to comments from posts).

Error

“No route matches {:action=>”show”, :controller=>”comments”, :post_id=>1, :id=>nil}
Try running rake routes for more information on available routes.”

show.html.erb:

<% @post.comments.each do |c| %>
<p>
  <b><%=h c.name %> said:</b><br />
  <%= c.created_at %>
</p>

<p>
  <%=h c.body %>
</p>

<p>
  <%=h c.id %>
</p>

<%= link_to 'test', post_comment_path(:post_id => @post.id, :id => c.id) %> |

<%#= link_to 'Edit', edit_post_comment_path(:id => @comment.id,
                                           :id => @post.id) %>

<%= link_to 'Comment', [@post, :comments ] %> |
<%= link_to 'Edit', edit_comment_path(@comment) %> |
<%= link_to 'Back', comments_path %>

When I remove this line, the error goes away.

<%= link_to ‘test’, post_comment_path(:post_id => @post.id, :id => c.id) %> |

rakes routes output:

   C:\RUBY\RailsInstaller\Ruby1.9.3\bin\ruby.exe -e  $stdout.sync=true;$stderr.sync=true;load($0=ARGV.shift)
    C:\RUBY\RailsInstaller\Ruby1.9.3\bin\rake routes
          posts_list GET    /posts/list(.:format)                       posts#list
       post_comments GET    /posts/:post_id/comments(.:format)          comments#index
                     POST   /posts/:post_id/comments(.:format)          comments#create
    new_post_comment GET    /posts/:post_id/comments/new(.:format)      comments#new
   edit_post_comment GET    /posts/:post_id/comments/:id/edit(.:format) comments#edit
        post_comment GET    /posts/:post_id/comments/:id(.:format)      comments#show
                     PUT    /posts/:post_id/comments/:id(.:format)      comments#update
                     DELETE /posts/:post_id/comments/:id(.:format)             comments#destroy
               posts GET    /posts(.:format)                            posts#index
                     POST   /posts(.:format)                            posts#create
            new_post GET    /posts/new(.:format)                        posts#new
           edit_post GET    /posts/:id/edit(.:format)                   posts#edit
                post GET    /posts/:id(.:format)                        posts#show
                     PUT    /posts/:id(.:format)                        posts#update
                     DELETE /posts/:id(.:format)                        posts#destroy

   Process finished with exit code 0

UPDATE:

The following now works. I needed to pass the id values within the link.

<%= link_to 'Edit', edit_post_comment_path(@post.id, c) %>

<%= link_to 'Destroy', [c.post, c], :confirm => 'Are you sure?', :method => :delete %>
  • 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-11T16:34:05+00:00Added an answer on June 11, 2026 at 4:34 pm

    Try this code for link generation

    <%= link_to 'test', post_comment_path(@post, c) %>
    

    or even

    <%= link_to 'test', [@post, c] %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting the below error when running my deployed app. Going by the
while running: rake snorby:setup getting below error: rake aborted! You have already activated rake
When running IIS, I'm getting the below error on all ASPX pages. ASP.NET is
I am getting below error when running a target of ANT script. Error message
I'm getting the below error while running the below script. My goal is to
I'm running kmeans on a large dataset and I'm always getting the error below:
I am getting conversion error when running the below sql in store procedure becasue
I am getting below error while running gzip command over ssh ssh 123@HPUX gzip
I was getting the below error when running scripts Problem while capturing system stateundefined
Hi im having an interesting problem. Update: From the comments im getting below this

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.