提交 ce5f27b0 编写于 作者: J Joshua Peek

Remove double scoping blocks and just use one

上级 c4df6332
......@@ -297,18 +297,16 @@ def resource(*resources, &block)
return self
end
controller(resource.controller) do
namespace(resource.name) do
with_scope_level(:resource, resource) do
yield if block_given?
get "", :to => :show, :as => resource.member_name
post "", :to => :create
put "", :to => :update
delete "", :to => :destroy
get "new", :to => :new, :as => "new_#{resource.singular}"
get "edit", :to => :edit, :as => "edit_#{resource.singular}"
end
scope(:path => resource.name, :controller => resource.controller) do
with_scope_level(:resource, resource) do
yield if block_given?
get "", :to => :show, :as => resource.member_name
post "", :to => :create
put "", :to => :update
delete "", :to => :destroy
get "new", :to => :new, :as => "new_#{resource.singular}"
get "edit", :to => :edit, :as => "edit_#{resource.singular}"
end
end
......@@ -333,24 +331,22 @@ def resources(*resources, &block)
return self
end
controller(resource.controller) do
namespace(resource.name) do
with_scope_level(:resources, resource) do
yield if block_given?
scope(:path => resource.name, :controller => resource.controller) do
with_scope_level(:resources, resource) do
yield if block_given?
with_scope_level(:collection) do
get "", :to => :index, :as => resource.collection_name
post "", :to => :create
get "new", :to => :new, :as => "new_#{resource.singular}"
end
with_scope_level(:collection) do
get "", :to => :index, :as => resource.collection_name
post "", :to => :create
get "new", :to => :new, :as => "new_#{resource.singular}"
end
with_scope_level(:member) do
scope(":id") do
get "", :to => :show, :as => resource.member_name
put "", :to => :update
delete "", :to => :destroy
get "edit", :to => :edit, :as => "edit_#{resource.singular}"
end
with_scope_level(:member) do
scope(":id") do
get "", :to => :show, :as => resource.member_name
put "", :to => :update
delete "", :to => :destroy
get "edit", :to => :edit, :as => "edit_#{resource.singular}"
end
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册