Question: I've been trying to aggregate and count records based on an association between 3 associations in a clean manner.

Okay, to begin I have:

**AdminUser**

```
has_many :jobs 
has_many :job_applications, through: :jobs

```

**JobApplications**

```
has_one :job_application_status_profile

```

**job\_application.rb**

```
class JobApplication < ApplicationRecord
 belongs_to :job
 belongs_to :user
 has_one :job_application_status_profile, dependent: :destroy
 after_create :create_job_application_status_profile
end

```

**job.rb**

```
class Job < ApplicationRecord
 belongs_to :admin_user
 has_many :job_applications, dependent: :destroy
end

```

**admin\_user.rb**

```
class AdminUser < ApplicationRecord
  has_many :jobs, dependent: :destroy
  has_many :job_applications, through: :jobs
end

```

I need to count how many records job application\_status profiles have is\_review\_complete through jobs -> job\_applications

```
current_admin_user.jobs.where(job_applications: {job_application_status_profile: {is_review_complete: false}}).size 

```

Simply put, but I get an error while doing that.

How can I count through the relationships with the fastest approach?

Answer: 
To fix, change your app's `build.gradle` from the following:

```
com.google.gms.googleservices.GoogleServicesPlugin = true

```

To:

```
googleServices.disableVersionCheck = true

```

There's some further discussion here:
<https://github.com/google/play-services-plugins/issues/36>
Go to Android studio SDK Manager and update or install google play services.
<https://developer.android.com/studio/intro/update.html#sdk-manager>