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

  • Home
  • SEARCH
  • 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 8459239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:16:59+00:00 2026-06-10T13:16:59+00:00

I am new in rails 3, and following the guide in ruby site I

  • 0

I am new in rails 3, and following the guide in ruby site I build the first blog application.

However in the app,the model “Comment” do not have edit/update/delete operation.

Then I tried to add it,but I fails.

Instead of just generate model for model “Comment”,I create the scaffold for model “Comment” using:

rails generate scaffold Comment commenter:string body:text post:references

And in the post.show page,I modify it like this:

<% @post.comments.each do |comment| %>
  <tr>
    <td><%= comment.commenter %></td>
    <td><%= comment.body %></td>
    <td><%= link_to 'Edit', edit_comment_path(comment) %></td>
    <td><%= link_to 'Destroy', comment, confirm: 'Are you sure?', method: :delete %></td>
  </tr>
<% end %>

They are listed,but when I click the ‘edit’ or ‘delete’ link,it will try to jump to:

http://localhost:3000/comments/1

And Then I will get the error:

No route matches [GET] "/comments/3/edit" or

No route matches [DELETE] "/comments/3"

I have no idea now.

Is there any demo out of box I can learn?


UPdate:

In the routes.rb:

resources :posts do
  resources :comments
end

Note:the following is confided manually by myself.

config generated by rails is :

resources :posts
resources :comments

Why I modify it is that in the comment build form,the post url should be “/posts/1/comments” for create new Comment,otherwise the post url will be “/comments” which will not associate the post and the comment.

  • 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-10T13:17:00+00:00Added an answer on June 10, 2026 at 1:17 pm

    Did you configure your routes? Your config/routes.rb should contain

    resources :comments
    

    you can also run rake routes to see what are the available url for your application based on your resource configuration.

    Edit:

    For a demo you can try this video on youtube. However, you can find lots of videos in web regarding this.

    Edit:

    So seems you need your comment resource in two ways. Both as a nested resource of posts and top level resource as well. So you can have two things together then

    resources :posts do
       resources :comments
    end
    resources :comments
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I an new in ruby and rails. Following the guide in ror document,I create
I'm new to Rails, and am following the getting started guide on their website.
I just created a new rails app in Rails 3.1.1, and my application layout
I'm current following the Rails Getting started guide, including creating a blog with post
I'm new to rails (using 3.2.1) and I was following the i18n-guide on rails
I am following the Rails guide for doing multi-model nested form. I have 2
I am quite new to Ruby and Ruby on Rails. While following a Ruby
Background: I made a new rails 3 app with User model and the model
Following the README documentation, I installed Devise into an existing Rails 3 application. However,
I'm new to Ruby on Rails, and I just finished following the getting started

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.