Check out example codes for "how to find attendance by date range in rails?". It will help you in understanding the concepts better.

Code Example 1

      <th>Total Present</th>
      <th>Total Absent</th>
    <% @manpowers.each do |manpower| %>
        <td><%= %></td>
        <td><%= manpower.attendance.date_between(from_date, to_date).present.count %></td>
        <td><%= manpower.attendance.date_between(from_date, to_date).absent.count %></td>
    <% end %>

Code Example 2

class Attendance < ActiveRecord::Base
  scope :absent, where(status: 0)
  scope :present, where(status: 1)
  scope :date_between, -> (from_date, to_date) { where(attendance_date: from_date..to_date) }

Learn ReactJs, React Native from