This project is archived and is in readonly mode.

#6137 ✓resolved
coffeeaddict_nl

routing polymorphic/sti resources seems broken

Reported by coffeeaddict_nl | December 9th, 2010 @ 09:29 AM

Hi,

I have an Order class which is the root of 2 other STI classes

class VirtualOrder < Order; end

class ConcreteOrder < Order; end

I also have a single OrdersController and want my Orders, VirtualOrders and ConcreteOrders to be handled by that controller. This is something that worked in Rails-2.x.x using old style routing like this:

  map.resources :orders, :member => { :cancel, :return }
  map.resources :virtual_orders,  :as => :orders
  map.resources :concrete_orders, :as => :orders

This allowed my to do a:

  link_to "here", @polymorpic_order

Which is - imho - expected behaviour.

Now I am in the middle of migrating my project to Rails3 and my resources look like this:

  resources :orders do
    member do
      get :return, :cancel
    end
  end
  
  resources :virtual_orders,  :as => "orders"
  resources :concrete_orders, :as => "orders"

I fully expected to still be feeding duck-typed objects into link_to and get the link to work. Now that still is true, but;

  undefined method concrete_order_path for #<#<Class:0xe265be8>:0xe25bae4>

get's raised

Obviously making a helper for that fixes my problem real easily but that would only be KISS, not DRY (and I don't like wet kisses... ;->)

And now, to get down to it, is this a bug? Or was it a bug in Rails2?

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>

Pages