From f950d0b4af54c3d387024dce2c5e2bc56aef0fc3 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 3 Nov 2009 11:23:22 -0600 Subject: Fix simple resource named routes for new routing dsl --- actionpack/lib/action_dispatch/routing/mapper.rb | 28 +++++++++++++++++------- 1 file changed, 20 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_dispatch/routing') diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index d6d822842b..ebfb4c9be2 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -20,15 +20,20 @@ module ActionDispatch return self end - controller(resource) do + singular = resource.to_s + plural = singular.pluralize + + controller(plural) do namespace(resource) do with_scope_level(:resource) do yield if block_given? - get "", :to => :show + get "", :to => :show, :as => "#{singular}" post "", :to => :create put "", :to => :update - delete "", :to => :destory + delete "", :to => :destroy + get "new", :to => :new, :as => "new_#{singular}" + get "edit", :to => :edit, :as => "edit_#{singular}" end end end @@ -54,22 +59,25 @@ module ActionDispatch return self end + plural = resource.to_s + singular = plural.singularize + controller(resource) do namespace(resource) do with_scope_level(:resources) do yield if block_given? member do - get "", :to => :show + get "", :to => :show, :as => "#{singular}" put "", :to => :update - delete "", :to => :destory - get "edit", :to => :edit + delete "", :to => :destroy + get "edit", :to => :edit, :as => "edit_#{singular}" end collection do - get "", :to => :index + get "", :to => :index, :as => "#{plural}" post "", :to => :create - get "new", :to => :new + get "new", :to => :new, :as => "new_#{singular}" end end end @@ -221,6 +229,10 @@ module ActionDispatch map_method(:delete, *args, &block) end + def root(options = {}) + match '/', options.merge(:as => :root) + end + def match(*args) options = args.last.is_a?(Hash) ? args.pop : {} -- cgit v1.2.3