Changeset 4643
- Timestamp:
- 08/01/06 01:23:06 (2 years ago)
- Files:
-
- trunk/actionpack/lib/action_controller/resources.rb (modified) (1 diff)
- trunk/actionpack/test/controller/resources_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/actionpack/lib/action_controller/resources.rb
r4642 r4643 35 35 36 36 def nesting_path_prefix 37 "#{path _prefix}/#{plural}/:#{singular}_id"37 "#{path}/:#{singular}_id" 38 38 end 39 39 trunk/actionpack/test/controller/resources_test.rb
r4642 r4643 1 1 require File.dirname(__FILE__) + '/../abstract_unit' 2 2 3 class MessagesController < ActionController::Base3 class ResourcesController < ActionController::Base 4 4 def index() render :nothing => true end 5 5 def rescue_action(e) raise e end 6 6 end 7 7 8 class CommentsController < ActionController::Base9 def index() render :nothing => trueend10 def rescue_action(e) raise eend11 end 8 class ThreadsController < ResourcesController; end 9 class MessagesController < ResourcesController; end 10 class CommentsController < ResourcesController; end 11 12 12 13 13 class ResourcesTest < Test::Unit::TestCase … … 117 117 def test_nested_restful_routes 118 118 with_routing do |set| 119 set.draw do |map| 120 map.resources(:messages) do |map| 121 map.resources(:comments) 122 end 123 end 124 125 with_options(:controller => 'comments', :message_id => '1') do |controller| 126 controller.assert_routing "/messages/1/comments", :action => 'index' 127 controller.assert_routing "/messages/1/comments.xml" , :action => 'index', :format => 'xml' 128 controller.assert_routing "/messages/1/comments/new", :action => 'new' 129 controller.assert_routing "/messages/1/comments/1", :action => 'show', :id => '1' 130 controller.assert_routing "/messages/1/comments/1;edit", :action => 'edit', :id => '1' 131 controller.assert_routing "/messages/1/comments/1.xml", :action => 'show', :id => '1', :format => 'xml' 132 end 119 set.draw do |map| 120 map.resources :threads do |map| 121 map.resources :messages do |map| 122 map.resources :comments 123 end 124 end 125 end 126 127 assert_simply_restful_for :threads 128 assert_simply_restful_for :messages, 129 :path_prefix => 'threads/1/', 130 :options => { :thread_id => '1' } 131 assert_simply_restful_for :comments, 132 :path_prefix => 'threads/1/messages/2/', 133 :options => { :thread_id => '1', :message_id => '2' } 133 134 end 134 135 end