3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'app/helpers/nitro_rails/resource_collection_helper.rb', line 3
def resource_collection(*resources_or_path, **options, &block)
if resources_or_path.last.is_a?(Symbol)
resources_method = resources_or_path[-1]
resources_type = resources_method.to_s.singularize
resources_parent = resources_or_path[-2]
resources_path = [resources_parent, resources_method]
resources = resources_parent.send(resources_method).where(options[:where])
else
resources_type = resources_or_path.first.table.name.singularize
resources = resources_or_path.first
end
ResourceCollection.new(resources, view: self, create_path: resources_path, parent: resources_parent, resource_type: resources_type, id: block.to_s.hash).render_content(&block)
end
|