Sha256: ea3718669a2ac829c4036abd2175319d894258c497c571f3b3e7ea7b94b1966a
Contents?: true
Size: 1.06 KB
Versions: 19
Compression:
Stored size: 1.06 KB
Contents
module AdminIt module ActiveRecordData # module CollectionContext def entities=(value) super(value) @count = @entities.nil? ? 0 : @entities.count end protected def load_entities collection = if AdminIt::Env.pundit? controller.policy_scope(entity_class) else entity_class.all end if child? collection = collection.where(parent.resource.name => parent.entity) end sort = {} sorting.each do |_sort| name, order = _sort.split(':') sort[name.to_sym] = order.to_sym end unless collection.nil? || sort.empty? collection = collection.order(sort) end collection end end # module TableContext def entities if @entities.count > page_size # limit collection to current page @entities = @entities .offset(page_size * (page - 1)) .limit(page_size) end super end end end end
Version data entries
19 entries across 19 versions & 1 rubygems