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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:52:15+00:00 2026-05-20T09:52:15+00:00

so i have got two models with each one controller: Model Project has_many Themes

  • 0

so i have got two models with each one controller:

Model Project has_many Themes

Model Theme belongs_to Project

in my routes file i added resources :projects and also for themes. Now i can add a project with localhost/projects/new which works fine and i can add Themes with localhost/themes/new. But thats not the way i want.

I only want to add Themes related to a project. Whats the best way to do this? I tried something like this: match "projects/:project_id/themes/new" => 'themes#new', :as => 'themes' which seems to work, but after submitting my new form nothing happens. the new form gets rendered again without a error message or something like that. my form tag in html gets rendered as the following:

<form accept-charset="UTF-8" action="/projects/3/themes/new" class="new_theme" id="new_theme" method="post">

do you have any ideas what went wrong? is there a best practice for something like that, because i think its a often wanted model.

  • 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-20T09:52:16+00:00Added an answer on May 20, 2026 at 9:52 am

    This situation is called nested resources.

    In your routes define:

    resources :projects do
      resources :themes
    end
    

    It will create exactly the url you described, as well as a bunch of helper methods. See the rails guides for a complete list, but here’s an example:

    To reach a single theme you would use projects_theme_path(@project, @theme), or to view all the themes for a project you would use projects_themes_path(@project). Again, see the rails guides for the full explanation and all the helpers.

    Also, at any time you can run rake routes to see the EXACT helper methods as they are set up for your project.

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

Sidebar

Related Questions

I have got two classes, one a subclass of the other (say Animal and
I've got two PostgreSQL databases that have been created using the same sql file.
I've got two Silverlight Controls in my project, both have properties TeamId. I would
I've got an ASP.NET MVC (VB) project with two models that represent two different
If I have two Models that have a manytomany relationship with a through model,
I have two strings: the first's value is catdog and the second's is got.
I've got a form where I have two radio buttons and two interchangeable controls
I've got a relatively simple question about asp.net MVC models. I've got a model
In this simplified scenario, I have a model called Post Each post has a
So i have a page that is gonna have multiple modal popups. Each one

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.