Assuming you have the proper has_many and belongs_to relationships setup, your query would probably look something like this:
Contract.joins(services: :worker)
.where(services: {worker_id: target_worker_id})
.where(contracts: {client_id: target_client_id}).uniq
where target_worker_id and target_client_id are the worker and clients you wish to filter by.
This query will join contracts to the services table (because you said "Contracts has many Services"), which also joins the services table to the workers table (because you said "Workers has many services"). In short, it appears that services is a join table, the result of a many-to-many relationship, hence the join clause.
Edit: Note the .uniq, which is necessary to ensure only distinct Contract objects are loaded. Otherwise, as you experienced, the inner join caused by the .join method will essentially create a collection of duplicates.
Let me know if I've misunderstood anything, or if you have additional questions on this answer.
Quick note: You wrote i obtain an array that is not an ActiveRecord and it cannot be used in the rails app (for example in erb). I'm not entirely clear what you mean, but any instance variable created in the controller can be used in ERB; it doesn't need to be an active record object. As stated though, I'm not sure if this is what you meant.