Count a occurence of given attribute

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

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 an example

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

Just do:

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

Ryan B.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs