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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:32:57+00:00 2026-05-14T00:32:57+00:00

I have read through the Rails docs for Routing , Restful Resources , and

  • 0

I have read through the Rails docs for Routing, Restful Resources, and the UrlHelper, and still don’t understand best practices for creating complex/nested routes. The example I’m working on now is for events, which has_many rsvps. So a user’s looking through a list of events, and clicks register, and goes through a registration process, etc. I want the urls to look like this:

/events
/events/123 # possible without title, like SO
/events/123/my-event-title # canonical version
/events/my-category/123/my-event-title # also possible like this
/events/123/my-event-title/registration/new
... and all the restful nested resouces.

Question is, how do I accomplish this with the minimal amount of code?

Here’s what I currently have:

map.resources :events do |event|
  event.resources :rsvps, :as => "registration"
end

That gets me this:

/events/123/registration

What’s the best way to accomplish the other 2 routes?

/events/123/my-event-title # canonical version
/events/my-category/123/my-event-title # also possible like this

Where my-category is just an array of 10 possible types the event can be.

I’ve modified Event#to_param to return "#{self.id.to_s}-#{self.title.parameterize}", but I’d prefer to have /id/title with the whole canonical-ness

  • 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-14T00:32:57+00:00Added an answer on May 14, 2026 at 12:32 am

    Because the SEO-friendly URLs you describe do not conform to the way Rails generates RESTful routes, you will need to use regular routes to set these up. For example:

    map.show_event 'events/:id/:event_title', :controller => 'events', :action => 'show'
    

    Don’t feel that you have to use the automatically generated RESTful routes for absolutely everything in your application. It’s not always a good fit for what you’re trying to do. Even the Rails routing guide says so:

    While RESTful routing has become the
    Rails standard, there are still plenty
    of places where the simpler regular
    routing works fine. You can even mix
    the two styles within a single
    application. In general, you should
    prefer RESTful routing when possible,
    because it will make parts of your
    application easier to write. But
    there’s no need to try to shoehorn
    every last piece of your application
    into a RESTful framework if that’s not
    a good fit.

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

Sidebar

Related Questions

I have read through the follow SO articles C#: How do I call a
I have read through several articles which are alternatives to using setpixel/getpixel but I
I have read through some tutorials about javascript prototypal inheritance patterns but I am
Okay guys, I have read through all the other posts and question on jQuery
This is probably not a dup; I have read through many similar problems on
Ok, I'm programming in objective-C and using Xcode. I have read through the documentation
I'm trying to have my application read through a text file and look for
I've read through a number of topics now and have not found one quite
I have read the boost asio reference, gone through the tutorial and looked at
I am creating a new rails app as a learning project. I have already

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.