Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7447

Show
Ignore:
Timestamp:
09/10/07 14:31:44 (1 year ago)
Author:
david
Message:

Fixed that resource namespaces wouldnt stick to all nested resources (closes #9399) [pixeltrix]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r7442 r7447  
    11*SVN* 
     2 
     3* Fixed that resource namespaces wouldn't stick to all nested resources #9399 [pixeltrix] 
    24 
    35* Moved ActionController::Macros::InPlaceEditing into the in_place_editor plugin on the official Rails svn #9513 [lifofifo] 
  • trunk/actionpack/lib/action_controller/resources.rb

    r7438 r7447  
    395395 
    396396          if block_given? 
    397             with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, &block) 
     397            with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block) 
    398398          end 
    399399        end 
     
    412412 
    413413          if block_given? 
    414             with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, &block) 
     414            with_options(:path_prefix => resource.nesting_path_prefix, :name_prefix => resource.nesting_name_prefix, :namespace => options[:namespace], &block) 
    415415          end 
    416416        end 
     
    420420        path_prefix = "#{options.delete(:path_prefix)}#{resource.nesting_path_prefix}" 
    421421        name_prefix = "#{options.delete(:name_prefix)}#{resource.nesting_name_prefix}" 
    422         namespace = options.delete(:namespace) 
    423422 
    424423        Array(options[:has_many]).each do |association| 
    425           resources(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => namespace
     424          resources(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => options[:namespace]
    426425        end 
    427426 
    428427        Array(options[:has_one]).each do |association| 
    429           resource(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => namespace
     428          resource(association, :path_prefix => path_prefix, :name_prefix => name_prefix, :namespace => options[:namespace]
    430429        end 
    431430      end 
  • trunk/actionpack/test/controller/resources_test.rb

    r7421 r7447  
    2020  class TagsController < ResourcesController; end 
    2121  class ManufacturersController < ResourcesController; end 
     22  class ImagesController < ResourcesController; end 
    2223 
    2324  module Admin 
    2425    class ProductsController < ResourcesController; end 
     26    class ImagesController < ResourcesController; end 
    2527  end 
    2628end 
     
    577579    end 
    578580  end 
     581   
     582  def test_nested_resources_using_namespace 
     583    with_routing do |set| 
     584      set.draw do |map| 
     585        map.namespace :backoffice do |backoffice| 
     586          backoffice.resources :products do |products| 
     587            products.resources :images 
     588          end 
     589        end 
     590      end 
     591 
     592      assert_simply_restful_for :images, :controller => "backoffice/images", :name_prefix => 'backoffice_product_', :path_prefix => 'backoffice/products/1/', :options => {:product_id => '1'} 
     593    end 
     594  end 
     595 
     596  def test_nested_resources_in_nested_namespace 
     597    with_routing do |set| 
     598      set.draw do |map| 
     599        map.namespace :backoffice do |backoffice| 
     600          backoffice.namespace :admin do |admin| 
     601            admin.resources :products do |products| 
     602              products.resources :images 
     603            end 
     604          end 
     605        end 
     606      end 
     607 
     608      assert_simply_restful_for :images, :controller => "backoffice/admin/images", :name_prefix => 'backoffice_admin_product_', :path_prefix => 'backoffice/admin/products/1/', :options => {:product_id => '1'} 
     609    end 
     610  end 
    579611 
    580612  protected