Rails 5:组合eager_load、left_joins与limit时返回数据集数量异常问题
带分页与多搜索功能的关联对象列表实现分享
嘿,跟大伙聊聊我正在做的这个列表页面——它用来展示三种关联对象,还自带分页功能和多种搜索筛选能力。
先给大家看看这三个对象的模型定义:
class Tree < ApplicationRecord has_many :samples end class Sample < ApplicationRecord belongs_to :tree has_many :projects_samples has_many :projects, through: :projects_samples end class Project < ApplicationRecord has_many :projects_samples has_many :samples, through: :projects_samples end
目前samples表里仅包含5个样本,每个样本都关联着一个Tree对象,其中第一个样本的具体关联细节如下:
(可补充具体关联内容)
内容的提问来源于stack exchange,提问作者Bioinf-IZ
相关产品推荐
相关产品推荐

