Just do: agent.confirm_clients.count(["confirm = ?", true])
----- Ryan Bigg Freelancer http://frozenplague.net On 31/12/2008, at 5:41 PM, Ishara Gunathilake wrote: > 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 > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---