0

我正在使用 gem Netzke 开发 Rails 应用程序。我有来自Netzke ::Basepack的 GridPanel和我自己的按钮。如何让他们通过我自己的 SQL 查询来过滤 GridPanel 的表?我试图像这样进行过滤:

def configure(c)
  super
  c.model = "Artist"
  c.columns = [{ name: "name", filter_with: lambda{|rel, value, op| rel.where("name like ? ", "Scorpions") } }]
end
4

1 回答 1

0

添加filter_with特定列可能不是您需要的。尝试使用scope网格上的选项:

def configure(c)
  super
  c.model = "Artist"
  c.scope = ->(rel) { rel.where("name like ?", "Scorpions") }
end
于 2015-11-19T01:06:06.517 回答