在我的rails项目中,我有模型:
class Panel < ActiveRecord::Base
has_many :surveys
scope :by_survey_name, ->(survey_name) {
joins(:surveys).where('surveys.survey_name LIKE (?)', "%#{survey_name}%")
}
end
问题是如何在activeadmin fiter中使用此范围?
答案 0 :(得分:6)
添加到模型:
(defn test-fn []
(client/head "https://google.com/404")
)
(with-handler! #'test-fn
java.lang.Exception
(fn [e] "error!"))
然后在资源中:
def self.ransackable_scopes(_auth_object = nil)
[:by_survey_name]
end