我尝试限定关联的范围,以便用户在编辑关系时看不到已经发送的提醒。但是,我希望它们出现在“show”视图中,而不是“edit”视图中。
我无法让作用域在每个字段的基础上工作。我可以使用proc来限定整个has_many调用的范围,但这不会让我在“显示”页面上显示结果,因为它是模型范围的。以下是我当前的代码,它似乎不能基于RailsAdmin维基工作:
group :reminders do
label 'Reminders'
field :reminders do
active true
associated_collection_scope do
Proc.new { |scope|
scope = scope.where(sent: false)
}
end
end
end发布于 2015-01-16 03:43:09
也许可以尝试将上面的代码放入edit do ; end块中。因此,将变成:
edit do
group :reminders do
label 'Reminders'
field :reminders do
active true
associated_collection_scope do
Proc.new { |scope|
scope = scope.where(sent: false)
}
end
end
end
end发布于 2014-01-21 01:45:02
associated_collection_cache_all true这应该会有帮助
https://stackoverflow.com/questions/16222136
复制相似问题