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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:49:48+00:00 2026-06-09T14:49:48+00:00

I am starting with rails and I am having a issue on nested routes

  • 0

I am starting with rails and I am having a issue on nested routes with 2 ids.

I submit a form from:

http://localhost:3000/admin/worlds/1/banks/new

And I get redirect to:

http://localhost:3000/admin/worlds/23/banks/23 

(with 23 being the id of the new bank)

The problem is that I can’t force this url to keep the first id = 1 as on the first route after the create action.

My Admin::Bank controller on the create here:

def create
  @world_bank = Admin::Bank.new(params[:admin_banque])
  @world_bank.world_id = params[:id]
  @world_bank.save!
  redirect_to admin_bank_path(@world_bank.world_id, @world_bank.id)
end

Routes:

namespace :admin do
   resources :mondes do
      member do
        resources :banques
    end
  end
end

And rake routes:

admin_banks GET    /admin/worlds/:id/banks(.:format)          admin/banks#index
POST   /admin/worlds/:id/banks(.:format)          admin/banks#create
new_admin_bank GET    /admin/worlds/:id/banks/new(.:format)      admin/banks#new
edit_admin_bank GET    /admin/worlds/:id/banks/:id/edit(.:format) admin/banks#edit
admin_bank GET    /admin/worlds/:id/banks/:id(.:format)      admin/banks#show
PUT    /admin/worlds/:id/banks/:id(.:format)      admin/banks#update
DELETE /admin/worlds/:id/banks/:id(.:format)      admin/banks#destroy

The fact is that I see:

:id/thing/:id/stuff when I know I should get :world_it/thing/:id/stuff

I’ve tried different way to use the redirect, especially the redirect_to admin_banks(world_id, id) for example, but it stayed the same.

I am pretty sure this could be fixed with a match in the routes.rb but I can’t make it work for now…

  • 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-09T14:49:50+00:00Added an answer on June 9, 2026 at 2:49 pm

    Get rid of the :member block around your nested resource & it should work. Try:

    namespace :admin do
      resources :mondes do
        resources :banques
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

http://localhost:3000/genre I'm using Instant Rails, I'm introducing scaffolding for the first time ever. So
I'm starting a new Rails 3.2.6 application. My nested route is failing when I
I'm starting learning rails, and having some troubles on configure cucumber to run my
Starting with Rails 3.0, from time to time, I've been receiving an exception notification
starting from the rails blog tutorial, i want to have listing and create functionality
I tried starting my Rails application but got this error message from Passenger: Ruby
I'm having problems starting my Rails web server. I try to enter rails server
Starting a new rails project and we have a well-thought-out color palette, and want
when starting Ruby on Rails programming, I will use rails first rails second and
I'm starting in the Rails world and i want to know how to put

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.