diff options
author | Andrew White <andyw@pixeltrix.co.uk> | 2010-06-28 12:04:13 +0100 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2010-06-28 14:22:35 +0200 |
commit | e717631a8481935e8ac1eeb2445da341bdd4c868 (patch) | |
tree | 03c0007b6306fbffaaece181d027268a4f1c23c0 /actionpack/lib/action_dispatch | |
parent | ccb21f20d86ffc17c10cb5e476912157c739dd96 (diff) | |
download | rails-e717631a8481935e8ac1eeb2445da341bdd4c868.tar.gz rails-e717631a8481935e8ac1eeb2445da341bdd4c868.tar.bz2 rails-e717631a8481935e8ac1eeb2445da341bdd4c868.zip |
Merge :constraints from scope into resource options [#2694 state:resolved]
Signed-off-by: José Valim <jose.valim@gmail.com>
Diffstat (limited to 'actionpack/lib/action_dispatch')
-rw-r--r-- | actionpack/lib/action_dispatch/routing/mapper.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 388f695187..62fb7977cc 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -433,6 +433,8 @@ module ActionDispatch end module Resources + MERGE_FROM_SCOPE_OPTIONS = [:shallow, :constraints] + class Resource #:nodoc: def self.default_actions [:index, :create, :new, :show, :update, :destroy, :edit] @@ -591,8 +593,6 @@ module ActionDispatch def resource(*resources, &block) options = resources.extract_options! - options = (@scope[:options] || {}).merge(options) - options[:shallow] = true if @scope[:shallow] && !options.has_key?(:shallow) if apply_common_behavior_for(:resource, resources, options, &block) return self @@ -619,8 +619,6 @@ module ActionDispatch def resources(*resources, &block) options = resources.extract_options! - options = (@scope[:options] || {}).merge(options) - options[:shallow] = true if @scope[:shallow] && !options.has_key?(:shallow) if apply_common_behavior_for(:resources, resources, options, &block) return self @@ -804,6 +802,10 @@ module ActionDispatch return true end + scope_options = @scope.slice(*MERGE_FROM_SCOPE_OPTIONS).delete_if{ |k,v| v.blank? } + options.reverse_merge!(scope_options) unless scope_options.empty? + options.reverse_merge!(@scope[:options]) unless @scope[:options].blank? + if resource_scope? nested do send(method, resources.pop, options, &block) |