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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:24:51+00:00 2026-05-14T21:24:51+00:00

I have this route: # config/routes.rb map.namespace :backshop, :path_prefix => ‘/:shop_id/admin’ do |backshop| backshop.resources

  • 0

I have this route:

# config/routes.rb
map.namespace :backshop, :path_prefix => '/:shop_id/admin' do |backshop|
  backshop.resources  :items
end

And I want to use the form_for magic to reuse the same form on both: new and edit views:

<% form_for [:backshop, @item] do |f| %>

This used to works, and used to build a create url for the item or update url for the item depending on the status of the @item object.

But this is not working on this case because the routes don’t exists without the shop_id parameter, and I don’t know how to say to the form_for something like this:

<% form_for [:backshop, @item], :shop_id => @shop do |f| %>

Because it tries to use the @item like the :shop_id parameter.

Or like this

<% form_for [:backshop, @shop, @item] do |f| %>

Because it tries to build this url:

backshop_shop_order_path

I Know I can just to extract the form_for declaration from the partial and do different calls on depending if new or edit:

<% form_for( @item, :url => backshop_items_path( @shop ) ) do |f| %>

and

<% form_for( @item, :url => backshop_item_path( @shop, @item ) ) do |f| %>

But I just wanted don’t do this because I have a bunch of models and is a few boring 🙂

Thanks for any suggestion

f.

  • 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-14T21:24:52+00:00Added an answer on May 14, 2026 at 9:24 pm

    Looks like you want to do nested resources with a namespace maybe you can rewrite your routes to something like

    map.namespace(:admin) do |admin|
      admin.resources :shops do |admin_shop|
         admin_shop.resources :item
      end
    end
    

    Now you should be able to use [@shop, @item] to get the route you want. Use rake routes to examine the routes and see if they are to your liking.

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

Sidebar

Related Questions

In my routes.rb I have this: map.namespace :admin do |admin| admin.resources :galleries do |galleries|
I'm using the friendly_id gem. I also have my routes nested: # config/routes.rb map.resources
I have the following route rule set in my config/routes.php: $route[add/url/(:any)] = add/url/$1/$2/$3; This
I have this resource in my config/routes.rb resources :users, :path => u do resources
I got a config/routes.rb file like this: map.resources :categories, :shallow => true do |cat|
I have the following in my config/routes.php file: $route['(:any)'] = dashboard/index/$1; This works as
ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I have the following URl: http://localhost:12981/BaseEvent/EventOverview/12?type=Film This is route: routes.MapRoute( Default, // Route name
I have a route that is suppose to match something like this localhost:3000/site/admin and
I have a route which routes a request to somepath/:id(.:format) to somecontroller#show . This

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.