diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-07-23 21:00:11 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-07-23 21:00:11 -0700 |
commit | d33eb07543aed1a07f9efe40ff7edc983b401957 (patch) | |
tree | ceaaa5d7ba9edca54e599d80bd44840511333860 /actionpack/lib | |
parent | d89a33d16216c9c3be719bda735bdc7a7f4bda00 (diff) | |
parent | dc1b0fd957246a05f7b490aa03970bcdcc9c48ba (diff) | |
download | rails-d33eb07543aed1a07f9efe40ff7edc983b401957.tar.gz rails-d33eb07543aed1a07f9efe40ff7edc983b401957.tar.bz2 rails-d33eb07543aed1a07f9efe40ff7edc983b401957.zip |
Merge pull request #2233 from gramos/fix-issue-1951-master
Fix issue 1951 master Namespaced model partial_path is wrong in namespaced controllers
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_view/renderer/partial_renderer.rb | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/actionpack/lib/action_view/renderer/partial_renderer.rb b/actionpack/lib/action_view/renderer/partial_renderer.rb index 51c784493e..c0ac332c4e 100644 --- a/actionpack/lib/action_view/renderer/partial_renderer.rb +++ b/actionpack/lib/action_view/renderer/partial_renderer.rb @@ -362,14 +362,28 @@ module ActionView def partial_path(object = @object) @partial_names[object.class.name] ||= begin object = object.to_model if object.respond_to?(:to_model) - object.class.model_name.partial_path.dup.tap do |partial| path = @lookup_context.prefixes.first - partial.insert(0, "#{File.dirname(path)}/") if partial.include?(?/) && path.include?(?/) + merge_path_into_partial(path, partial) end end end + def merge_path_into_partial(path, partial) + if path.include?(?/) && partial.include?(?/) + overlap = [] + path_array = File.dirname(path).split('/') + partial_array = partial.split('/')[0..-3] # skip model dir & partial + + path_array.each_with_index do |dir, index| + overlap << dir if dir == partial_array[index] + end + + partial.gsub!(/^#{overlap.join('/')}\//,'') + partial.insert(0, "#{File.dirname(path)}/") + end + end + def retrieve_variable(path) variable = @options[:as].try(:to_sym) || path[%r'_?(\w+)(\.\w+)*$', 1].to_sym variable_counter = :"#{variable}_counter" if @collection |