diff options
author | Yehuda Katz <wycats@gmail.com> | 2009-08-07 00:52:13 -0300 |
---|---|---|
committer | Yehuda Katz <wycats@gmail.com> | 2009-08-07 00:52:13 -0300 |
commit | 70a440aa277676078e3b8baafe1101d1287e114f (patch) | |
tree | 6a0b071cbedde4f4edc481272264d014637e7e90 /actionpack/lib/action_view/render | |
parent | 4ac9d391d337d5a05a7aa93849405e21dd4bbf01 (diff) | |
download | rails-70a440aa277676078e3b8baafe1101d1287e114f.tar.gz rails-70a440aa277676078e3b8baafe1101d1287e114f.tar.bz2 rails-70a440aa277676078e3b8baafe1101d1287e114f.zip |
Clean up render @object a bit more.
Diffstat (limited to 'actionpack/lib/action_view/render')
-rw-r--r-- | actionpack/lib/action_view/render/partials.rb | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/actionpack/lib/action_view/render/partials.rb b/actionpack/lib/action_view/render/partials.rb index 581742e875..6e5810d148 100644 --- a/actionpack/lib/action_view/render/partials.rb +++ b/actionpack/lib/action_view/render/partials.rb @@ -177,6 +177,12 @@ module ActionView attr_accessor :_partial end + module ClassMethods + def _partial_names + @_partial_names ||= ActiveSupport::ConcurrentHash.new + end + end + def render_partial(*args) @assigns_added = false _render_partial(*args) @@ -189,12 +195,9 @@ module ActionView if partial.respond_to?(:to_ary) return _render_partial_collection(partial, options) - elsif partial.is_a?(ActionView::Helpers::FormBuilder) - path = partial.class.model_name.partial_path - options[:locals].merge!(path.to_sym => partial) elsif !partial.is_a?(String) options[:object] = object = partial - path = ActionController::RecordIdentifier.partial_path(object, controller_path) + path = _partial_path(object) end parts = partial_parts(path, options) @@ -203,6 +206,17 @@ module ActionView end private + def _partial_path(object) + self.class._partial_names[[controller.class, object.class]] ||= begin + name = object.class.model_name + if controller_path && controller_path.include?("/") + File.join(File.dirname(controller_path), name.partial_path) + else + name.partial_path + end + end + end + def partial_parts(name, options) segments = name.split("/") parts = segments.pop.split(".") @@ -278,8 +292,7 @@ module ActionView index, @_partial_path = 0, nil collection.map do |object| options[:_template] = template = passed_template || begin - _partial_path = - ActionController::RecordIdentifier.partial_path(object, controller_path) + _partial_path = _partial_path(object) template = _pick_partial_template(_partial_path) end |