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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:56:48+00:00 2026-05-22T17:56:48+00:00

Rails is giving me urls that have the ids in the wrong order. It’s

  • 0

Rails is giving me urls that have the ids in the wrong order. It’s handing the parent id to the child and the child id to the parent.

In my routes.rb I have

resources :calendars do
  resources :events
end

which rake routes tells me is setting up good routes, e.g.

calendar_event GET    /calendars/:calendar_id/events/:id(.:format)      {:controller=>"events", :action=>"show"}

So when I ask for the path for that route from my view partial,

<%= link_to "#{event.name} @ #{event.calendar.name} #{event.calendar.year}", calendar_event_path(event) %>

it gives me a url that has the ids reversed…

http://localhost:3000/calendars/<-eventid->/events/<-calendarid->

Any help would be appreciated!!!

Edit: in my model, Event belongs_to :calendar and Calendar has_many :events. I’m also using Mongoid as my ORM, not ActiveRecord, though I hope that isn’t the issue.

  • 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-05-22T17:56:49+00:00Added an answer on May 22, 2026 at 5:56 pm

    When you use the nested resource’s URL helper calendar_event_path you need to provide it the calendar object (or ID) too, eg:

     calendar_event_path(event.calendar, event)
    

    An alternative is:

     <%= link_to "#{event.name} @ #{event.calendar.name} #{event.calendar.year}", [event.calendar, event] %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a new application that is giving me errors when I do rails
Rails make It possible to map resources that are logically children of other resources
Rails has a nice idiom that makes it easy for you to have a
We are just giving MongoDB a test run and have set up a Rails
Rails likes giving all of my fields the same IDs when they are generated
I currently have a Rails website that has some Prototype scripting in it. My
A have a XML helper that is giving the error: NoMethodError in Admin/xml#index Showing
I have a Rails application that I want to be able to jump to
In my Rails app, when creating a business I have a form that has
When I try to run 'rails server' it's giving me an error saying that

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.