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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:39:28+00:00 2026-06-08T00:39:28+00:00

I have two models: team and project routes.rb resources :teams do resource :projects end

  • 0

I have two models: team and project

routes.rb

resources :teams do
  resource :projects
end

And two questions!

1- According to http://guides.rubyonrails.org/routing.html, I expect to get teams/:team_id/projects/:id path. However, this is not the case.

rake routes

         team_projects POST     /teams/:team_id/projects(.:format)      projects#create
     new_team_projects GET      /teams/:team_id/projects/new(.:format)  projects#new
    edit_team_projects GET      /teams/:team_id/projects/edit(.:format) projects#edit
                       GET      /teams/:team_id/projects(.:format)      projects#show
                       PUT      /teams/:team_id/projects(.:format)      projects#update
                       DELETE   /teams/:team_id/projects(.:format)      projects#destroy

so I had to name route to get it working

  match 'teams/:team_id/projects/:id' => 'projects#show', :via => [:get], :as => :show_project

so how can take advantage of rails helper methods instead of naming them?


2- In project show action view, the debugger throws these parameters for me:

action: show
controller: projects
team_id: '1'

which is fine. but when I click on “new_team_projects_path” url, it redirects me to the same view and the debugger throws these parameters:

controller: projects
action: show
team_id: '1'
id: new

It doesn’t redirect me to the new action, but it took “new” as an ID! why?

  • 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-08T00:39:31+00:00Added an answer on June 8, 2026 at 12:39 am
    1. You need to use

      resources :teams do
        resources :projects
      end
      

      Note the plural! resource produces a singular route without id.

    2. won’t be relevant anymore with the first fix.

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

Sidebar

Related Questions

I have two models Horse and Race. class Horse < ActiveRecord::Base has_many :races end
I have two models Project and UrlList . A project :has_many url_list and a
I have the following models: class Match < ActiveRecord::Base has_and_belongs_to_many :teams end And class
Let's imagine we have two models: Teams: Id, Name Player: Id, Name, TeamId I
I have two models: Users and Projects. The idea is that Users can follow
I have two models, Teams and Players. On the teams index page I have
So, here is the deal: I have two models, a Player and a Team.
hi i have to following model class Match(models.Model): Team_one = models.ForeignKey('Team', related_name='Team_one') Team_two =
I have two models, Listing and Invitation, associated with has_and_belongs_to_many. I am looking at
I have two Models, Programme and Event, a programme has many events. I need

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.