Query to get distinct "function_id" counts in rails
===

I am new to programming as well as rails. I have a basic question here.
I am doing a join query like " **FunctionCall.joins(:solution).where(:solutions => {:problem_id => 517})** " and the result is shown below

    FunctionCall id: 1, solution_id: 64453, function_id: 1
    FunctionCall id: 2, solution_id: 64429, function_id: 1
    FunctionCall id: 3, solution_id: 64452, function_id: 3
    FunctionCall id: 4, solution_id: 64453, function_id: 2
    FunctionCall id: 5, solution_id: 64451, function_id: 2
 
Now what i wanted here is to get the counts of distinct function_ids which in this case should be **function_id_1_count = 2 , function_id_2_count = 2 , function_id_3_count = 1**