This project is archived and is in readonly mode.

#3911 ✓committed
Jan De Poorter

naming problem in nested singular resource

Reported by Jan De Poorter | February 9th, 2010 @ 03:00 PM | in 3.0.2

When nesting singular resources the naming is off. Instead of having resource1_resource2_path, I just get resource2_path method for the route.

In Rails 2.3 syntax

map.resource :account do |acc|
 acc.resource :payment_plan
end

Which results in

 new_account_payment_plan GET    /account/payment_plan/new(.:format)                        {:controller=>"payment_plans", :action=>"new"}
edit_account_payment_plan GET    /account/payment_plan/edit(.:format)                       {:controller=>"payment_plans", :action=>"edit"}
     account_payment_plan GET    /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"show"}
                          PUT    /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"update"}
                          DELETE /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"destroy"}
                          POST   /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"create"}

Rails 3 syntax

resource :account do
  resource :payment_plan
end

which results in

                          GET    /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"show"}
                          POST   /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"create"}
                          PUT    /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"update"}
             payment_plan DELETE /account/payment_plan(.:format)                            {:controller=>"payment_plans", :action=>"destroy"}
         new_payment_plan GET    /account/payment_plan/new(.:format)                        {:controller=>"payment_plans", :action=>"new"}
        edit_payment_plan GET    /account/payment_plan/edit(.:format)                       {:controller=>"payment_plans", :action=>"edit"}

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Referenced by

Pages