This project is archived and is in readonly mode.

#4328 ✓resolved
Andrew White

Missing support for actions on a new resource in new routing DSL

Reported by Andrew White | April 5th, 2010 @ 07:09 AM | in 3.0.2

The deprecated mapper supported adding resource actions that operated on a new resource, e.g:

  # /posts/new/preview
  map.resources :posts, :new => { :preview => :post }

The attached patch adds support for this to the new routing DSL. e.g:

  resources :posts do
    new do
      post :preview
    end
  end

To add this behaviour to singleton resources I've had to make a breaking DSL change. Rather than directly specifying member actions inside the resource block, they need to be nested inside a member block. e.g:

  resource :account do
    get :info # Now raises an exception
  end

  resource :account do
    member do
      get :info
    end

    new do
      post :preview
    end
  end

I did look at still allowing member routes on singleton resources to be specified directly inside the resource block but I personally felt it was better to have a consistent DSL.

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