Method: EffectiveResourcesHelper#render_resource_partial
- Defined in:
- app/helpers/effective_resources_helper.rb
#render_resource_partial(resource, atts = {}) ⇒ Object Also known as: render_resource
Similar to render_resource_form
179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 |
# File 'app/helpers/effective_resources_helper.rb', line 179 def render_resource_partial(resource, atts = {}) unless resource.kind_of?(ActiveRecord::Base) || resource.class.ancestors.include?(ActiveModel::Model) raise 'expected first argument to be an ActiveRecord or ActiveModel object' end raise 'expected attributes to be a Hash' unless atts.kind_of?(Hash) effective_resource = (atts.delete(:effective_resource) || find_effective_resource) action = atts.delete(:action) safe = atts.delete(:safe) atts = { :namespace => (effective_resource.namespace.to_sym if effective_resource.namespace), effective_resource.name.to_sym => resource }.compact.merge(atts) if lookup_context.template_exists?(effective_resource.name, controller._prefixes, :partial) return render(effective_resource.name, atts) end effective_resource.view_paths.each do |view_path| if lookup_context.template_exists?(effective_resource.name, [view_path], :partial) return render(view_path + '/' + effective_resource.name, atts) end end # Will raise the regular error return ''.html_safe if safe render(resource, atts) end |