1
問題是我無法調用過濾器中使用的方法。如何在過濾器數據網格中調用方法
在sameple_grid.rb
我有查詢的所有記錄的樣品的方法加入
def method_sameple(field, operation, value)
ids = Model2.joins(:model2_model3s).where("score#{operation} ? AND model3_id= ?", value, field).ids
Model1.joins(:model2s).where(model2: { id: ids})
end
那麼我調用method_sample
filter(:name, :dynamic, select: [[name, id]], header: -> { 'Name' }) do |(field, operation, value), scope|
#mehtod need to call in here!
end
我已經使用datagrid gem進行過濾,我有一個在其他過濾器中使用的方法。我不想在其他過濾器中編寫相同的查詢 – pitou