我正在尝试进行数据库查询,它只返回 has_many 关系不为空的结果。下面是 has_many :gift_images 的示例:
Gift.joins(:gift_images).includes(:gift_images, :comments, :category, :user).select("gifts.*, COUNT(gift_images.id) AS gcount").where("gcount > 0")
类似的东西,但它不起作用。有任何想法吗?
我正在尝试进行数据库查询,它只返回 has_many 关系不为空的结果。下面是 has_many :gift_images 的示例:
Gift.joins(:gift_images).includes(:gift_images, :comments, :category, :user).select("gifts.*, COUNT(gift_images.id) AS gcount").where("gcount > 0")
类似的东西,但它不起作用。有任何想法吗?