[Solved] How to find out the number of records in a table? [closed]


It would be something like this on your model:

def self.pending_count
 where(status: 0).count
end


def self.in_progress_count
 where(status: 1).count
end

def self.finished_count
 where(status: 2).count
end

Then you can just call Model.pending_count (or the other methods) wherever you need it.

solved How to find out the number of records in a table? [closed]