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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:36:52+00:00 2026-06-17T05:36:52+00:00

I have a routing error, but I think my routes are correct: Routing Error

  • 0

I have a routing error, but I think my routes are correct:

Routing Error

No route matches {:controller=>"posts", :action=>"edit", :user_id=>#<Post id: 9, title: "Na Curva do Horizonte", content: "Eu na mesma minha opinião no pensamento vejo me ca...", created_at: "2013-01-12 20:41:57", updated_at: "2013-01-12 20:41:57", image_file_name: "iris_by_archang3lzz-d5k2i5l.jpg", image_content_type: "image/jpeg", image_file_size: 1101282, image_updated_at: "2013-01-12 20:41:56", user_id: 5>}
Try running rake routes for more information on available routes.

When I execute rake routes, the results are correct:

       user_posts GET    /user/:user_id/posts(.:format)              posts#index
                  POST   /user/:user_id/posts(.:format)              posts#create
    new_user_post GET    /user/:user_id/posts/new(.:format)          posts#new
   edit_user_post GET    /user/:user_id/posts/:id/edit(.:format)     posts#edit
        user_post GET    /user/:user_id/posts/:id(.:format)          posts#show

My routes are:

 resources :posts

  resources :user  do
    resources :posts,:comments
  end

  resources :posts do
    resources :comments
  end

and the link in error is:

<%= link_to 'Edit', edit_user_post_path(notice) %>

I don’t know what is wrong.

  • 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-17T05:36:53+00:00Added an answer on June 17, 2026 at 5:36 am

    Since you want to edit a specific post which belongs to a specific user, you need to pass in those two as parameters to that link, putting the parent first. Otherwise rails doesn’t know which post you are about to edit.

    <%= link_to 'Edit', edit_user_post_path(@user, @post) %>
    

    So all you seem to need is those two variables.

    Read you rake routes carefully. It says:

    /user/:user_id/posts/:id/edit(.:format)
    

    So there you can see that you need :user_id as well as :id, which refers to the post. Giving the objects as parameters will be enough, rails is smart enough to figure out their ids and use them for the link.

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

Sidebar

Related Questions

the default route is :controller/:action/:id but I want just : controller/:action for my errors
I have my own routing rules in routes.php, defined for all the pages that
I have a custom routing application that takes information for a route from google
I have some CRUD routing: /news/{page} // public /news/new // private /news/{slug}/show //public /news/{slug}/edit
I have a similar question as Ruby on Rails. Unicode routes but the answer
I have a form that is suppose to be a POST to CREATE action
NOTE: I have read Routing From the Inside Out AND the Engine Yard blog
I am using symfony 1.0 and have set routing for few URLs as below.
I have a few routing issues with my ASP.NET MVC2 website and was wondering
I have to get routing direction i.e. all the lat-long location between two location

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.