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

  • Home
  • SEARCH
  • 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 7666987
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:58:50+00:00 2026-05-31T14:58:50+00:00

I have a model named Entree for which the new action needs a parameter,

  • 0

I have a model named Entree for which the new action needs a parameter, the id of another model named Cave. I don’t want to nest Entree in Cave since Cave is already nested.
What I did was declaring the resource Entree as follow in routes.rb:

resources :entrees, :except => [:new]
match "/entrees/new/:id", :to => "Entrees#new", :as => 'new_entree'

That works, but the problem is when there’s an error in the create action, I want to display the page again with the invalid input. But since there’s no new action, I must do a redirect_to new_entree_path, which does not keep the user input.

I have tried the following (simplest) route:

resources :entrees

But then the path http://localhost:3000/entrees/new/32 returns an error:

No route matches [GET] "/entrees/new/32"

The question is, how can I declare the Entree resource in the routes file with a parameter for the new action ?

  • 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-31T14:58:52+00:00Added an answer on May 31, 2026 at 2:58 pm

    I’m not sure if that’s a hack or not, but the following works and seems cleaner than 2-levels nesting.

    resources :entrees, :except => [:new] do
      collection do
        get 'new/:id', :to => "entrees#new", :as => 'new'
      end
    end
    

    Now I can do a render "new" instead of a redirect_to.
    I must say that I must have asked my question wrongly, my bad.

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

Sidebar

Related Questions

I have a model named clothing which I want to be the singlular (one
I have a relatively simple problem. I have a model named Item which I've
I have a model service and a ModelForm named Service which I use to
I have a model named UserPrice which has the attribute :purchase_date (a date_select) in
I have a model named Order and another model named Member and when I
I want to import data with YAML. I have a model named Question package
In my model named Profile_model I have this function which retrieves profile data for
On a Content model have an attribute named slug . When creating a new
I have a model named Domain which looks like this: class Domain(models.Model): Model for
I have a model named Post. I want to use a modal form to

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.