【发布时间】:2021-05-24 09:51:57
【问题描述】:
我用过滤器撞墙了。
我有两个模型和相关的 rails_admin conf:
class ImageBase < ApplicationRecord
has_and_belongs_to_many :authors, optional: true
[...]
end
class Author < ApplicationRecord
has_and_belongs_to_many :image_bases, class_name: 'ImageBase'
[...]
end
config.model 'ImageBase' do
list do
scopes [:published, :draft, nil]
filters %i[collocazione authors]
[...]
field :authors do # (4)
eager_load true
queryable true
visible true
searchable %i[name surname]
end
search_by :search_image_base_admin
end
end
我的问题是,当我在 Rails_admin 中按作者过滤 ImageBase 时,结果只显示匹配的作者,而不是与图像库记录相关的所有作者。
我主要需要这个来导出过滤后的数据,这不仅仅是列表视图中的问题(我可以忍受)
在文档和网络上都找不到解决方案, 有什么建议/解决方案吗?
谢谢 弗朗切斯科
【问题讨论】:
-
我不明白你的问题,当你说“to the imagebase record”时,你是什么意思?您正在配置图像库记录列表,因此如果您按单个演员过滤,您将仅获得与该特定演员相关的图像库记录。你能重新提出你的问题吗?
-
我的意思是:当我在 rails_admin 中按作者(关系 m2m)过滤 ImageBase(我的主表)时,结果只显示我在 ImageBase 结果中过滤的同一作者,而不是所有作者与记录有关。示例:ImageBaseRecord1 <23>23>