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

<table>
  <thead>
    <tr>
      <th>Name</th>
      <th>Total Present</th>
      <th>Total Absent</th>
    </tr>
  </thead>
  <tbody>
    <% @manpowers.each do |manpower| %>
      <tr>
        <td><%= manpower.name %></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>
      </tr>
    <% end %>
  </tbody>
</table>

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) }
end

Learn ReactJs, React Native from akashmittal.com