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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:03:42+00:00 2026-06-04T03:03:42+00:00

I am working on a small assignment to create posts and divide them by

  • 0

I am working on a small assignment to create posts and divide them by categories. I have everything working but in my index.html I’m getting the following routing errors related to my links.

No route matches {:action=>"show", :controller=>"posts"}
No route matches {:action=>"edit", :controller=>"posts"}
undefined method `post_path' for #<#<Class:0x007fd3097f0ce0>:0x007fd3097c9370>

In posts/index.html.haml I have:

    - @category.posts.each do |post|
        %tr
          %td= post.title
          %td= post.description
          %td= post.user_id
          %td= post.category_id
          %td= link_to 'Show', category_post_path //gives first error
          %td= link_to 'Edit', edit_category_post_path //gives second error
          %td= link_to 'Destroy', post, 
          :confirm => 'Are you sure?', :method => :delete //gives third error

In routes.rb I have:

resources :categories do
    resources :posts
  end

When I run rake routes I get:

categories_index  GET    /categories/index(.:format)    categories#index                
category_posts    GET    /categories/:category_id/posts(.:format)     posts#index
                  POST   /categories/:category_id/posts(.:format)          posts#create
new_category_post GET    /categories/:category_id/posts/new(.:format)      posts#new
edit_category_postGET    /categories/:category_id/posts/:id/edit(.:format) posts#edit
category_post     GET    /categories/:category_id/posts/:id(.:format)      posts#show
                  PUT    /categories/:category_id/posts/:id(.:format)      posts#update
                  DELETE /categories/:category_id/posts/:id(.:format)      posts#destroy

There is something wrong in my index that is making the application crash because I can access and see these with no problems:

/categories/:category_id/posts/:id (equivalent to show)
/categories/:category_id/posts/:id/edit (equivalent to edit)

Can someone please help me out? Thank you in advance.

  • 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-04T03:03:44+00:00Added an answer on June 4, 2026 at 3:03 am

    The URL helpers need to know which category and post you’re interested in so you have to pass the specific category and post objects as parameters to the helpers. I think these should work:

          %td= link_to 'Show', category_post_path(@category,post) //gives first error
          %td= link_to 'Edit', edit_category_post_path(@category,post) //gives second error
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a small homework assignment and I'm supposed to make a food
Iam working on small booking room system. In my solution I have a Reservation
Im working on a small application to try out an idea that I have.
i was working with a small routine that is used to create a database
This is a school assignment and I have most of it under control, but
I am working on a homework assignment where I have to implement a MergeSort
I am working on small web application for iPad Safari. I have to display
Having some issues with one small function I'm working on for a homework assignment.
We have service that's working with small to large sets of data (document generation),
Working on a small web application, I have a user table in which user

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.