I'm just upgrading my app to Rails 3 and as I have to rewrite my routing anyway, I'm taking some time to improve my named routes.
I have an invoices controller which has a trash action (/invoices/trash lists all invoices in trash). I want to access this through a named route (i.e. trash_url) for simplicity in my views.
I can achieve this easily enough with the following
match "/invoices/trash" => "invoices#trash", :as => :trash
What I want to know is if there is a way of doing this within the block where I define the routes for my invoice controller. I have tried the following and it doesn't work.
resources :invoices do
collection do
get :trash, :as => :trash
end
end
Is what I am trying to do possible or do I have to define my named route outside of this block?
Thanks.