As @BroiSatse already mentioned, you can use ActiveRecord::Base.table_nameto explicitly specify the table name in the model and get the table name in the query for universality.
The request will look like this:
User.joins(:comments).where(Comment.table_name: {something: 1}).count
Directly setting the table name:
class Comment < ActiveRecord::Base
self.table_name = "x_comments"
end
table_name :
class Comment < ActiveRecord::Base
def self.table_name
"x_" + super
end
end
Comment.table_name