Count a occurence of given attribute

hi,
i have a two tables named “agents” and “confirm_clients”
in confirm_clients columns
t.column :client_id, :string
t.column: agent_id, :string
t.column:confirm, :boolean

agents
t.column :agent_id, :string
t.column :rank, :integer

i want to count the occurence of each agent_id ,which the
confirm boolean is “true” and i want to save that count number
in the rank column of agents table.as an example

if confirm_clients table agent_id=agent1 has 4 boolean true rows so i
want
to save 4 in
the agents table rank column,corresponding agent1s row.plz can anyone
help
me to
solve this problem

Just do:

agent.confirm_clients.count([“confirm = ?”, true])


Ryan B.
Freelancer