mirror of
https://github.com/github/rails.git
synced 2026-04-04 03:00:58 -04:00
Nesting map.resources
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4642 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
@@ -69,15 +69,15 @@ module ActionController
|
||||
end
|
||||
end
|
||||
|
||||
def resources(*entities)
|
||||
def resources(*entities, &block)
|
||||
options = entities.last.is_a?(Hash) ? entities.pop : { }
|
||||
entities.each { |entity| map_resource(entity, options.dup) { yield if block_given? } }
|
||||
entities.each { |entity| map_resource entity, options.dup, &block }
|
||||
end
|
||||
|
||||
private
|
||||
def map_resource(entities, options = {}, &block)
|
||||
resource = Resource.new(entities, options)
|
||||
|
||||
|
||||
with_options :controller => resource.controller do |map|
|
||||
map_collection_actions(map, resource)
|
||||
map_new_actions(map, resource)
|
||||
@@ -154,4 +154,4 @@ module ActionController
|
||||
end
|
||||
end
|
||||
|
||||
ActionController::Routing::RouteSet::Mapper.send :include, ActionController::Resources
|
||||
ActionController::Routing::RouteSet::Mapper.send :include, ActionController::Resources
|
||||
|
||||
@@ -114,15 +114,15 @@ class ResourcesTest < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
def xtest_nested_restful_routes
|
||||
def test_nested_restful_routes
|
||||
with_routing do |set|
|
||||
set.draw do |map|
|
||||
map.resources(:messages) do
|
||||
map.resources(:messages) do |map|
|
||||
map.resources(:comments)
|
||||
end
|
||||
end
|
||||
|
||||
with_options({ :controller => :comments }) do |controller|
|
||||
with_options(:controller => 'comments', :message_id => '1') do |controller|
|
||||
controller.assert_routing "/messages/1/comments", :action => 'index'
|
||||
controller.assert_routing "/messages/1/comments.xml" , :action => 'index', :format => 'xml'
|
||||
controller.assert_routing "/messages/1/comments/new", :action => 'new'
|
||||
|
||||
Reference in New Issue
Block a user