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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:21:24+00:00 2026-05-17T20:21:24+00:00

Is it possible to override a RESTful path? For instance, I have photo_path(photo) which

  • 0

Is it possible to override a RESTful path?

For instance, I have photo_path(photo) which would generate /photos/12345

But I’d like for all uses of photo_path to actually generate URL’s like /photos/joeschmoe/12345 (which is the photo’s user and the photo id).

Obviously I could just create a new route, but wanted to make sure there wasn’t a more RESTful way of doing it.

  • 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-17T20:21:24+00:00Added an answer on May 17, 2026 at 8:21 pm

    You could make photos a sub-resource to user’s, so you’d have users/joeschmoe/photos/12345 (of course here, your users controller would require the ability to accept a username instead of an id, which is another routing problem to solve but not difficult)

    resources :users do
      resources :photos
    end
    

    Then your controller could maybe call

    @photos = Photo.find_by_username(params[:id])
    

    Although I think there are less hacky ways of doing that.

    You could also add joeschmoe as a query string parameter.

    Or you could make username an optional parameter in the route, so it would be something like

    match "/photos(/:username)/:id" => "photos#show"
    

    Or if you want a new named route:

    match "/photos/:username/:id" => "photos#show_by_user", :as => :user_photo
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to override the equivalence comparison in Javascript? The closest I have
Would it be possible to override the 'require' command so that it will try
Is it possible to override the settings in war file's WEB-INF/jboss-web.xml? I have a
I would expect something like this to work but the ListItem, BeforeProperties, AfterProperties are
Is it currently possible to override the structure constructor in Fortran? I have seen
EF requires parameterless constructor but is it possible to override this some how? public
Is it possible to override (C-style) casts in C++? Suppose I have the code
Is it possible to override new on a polymorphic class, and if so how?
Is it possible to override reflection functionality ?
Is it possible to override a generisized function as illustrated in the code snippet

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.