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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:44:19+00:00 2026-06-09T13:44:19+00:00

I have routes like this: resources :users do resources :projects end I would like

  • 0

I have routes like this:

resources :users do
  resources :projects
end

I would like to be able to access routes like this:

/users/1/projects/1

and

/projects/1

Is this possible? How would I set this up? I’m having and issue in my app where we would like to have users able to see both their own projects via /users/:id/projects/:id but also on other pages we’d like to just see all the projects created, like this /projects or a project and an id, like this /projects/:id. I feel like I’m missing something, should I just get rid of the nested routes? Or can I have both.

  • 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-09T13:44:21+00:00Added an answer on June 9, 2026 at 1:44 pm

    You can have both. Just add resources :projects to your routes.rb.
    Then, in your ProjectsController you will have to do:

    def index
      if params[:user_id]
        @projects = User.find(params[:user_id]).projects
      else
        @projects = current_user.projects
      end
    end
    

    I’m assuming your authentication system provides with current_user method for your controllers (as most of them do)

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

Sidebar

Related Questions

In Rails 3 edge, I have set up two nested resources like this: config/routes.rb
I have a nested resource in my routes.rb like this: map.resources :users, :only =>
I currently have a routes.rb file that looks like this: map.resources :profiles do |profile|
I have this devise_for :users resources :sites do resources :users get 'companies/search' end root
I have the following routes, which allows for urls like /:username/:project_name resources :users, :path
In my routes, I have: resources :users do resources :articles end Which will allow
I have a router like this, as main entry point: window.AppRouter = Backbone.Router.extend({ routes:
I'm using Expressjs w/ node.js and I have a route like this: users.init(app.db, function()
I would like to change my default route values. Right now, I have: routes.MapRoute(
I have a constrained route that matches usernames like this: controller :users, :path =>

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.