Use ActiveRecord scope in ActiveAdmin filter
问题 In my rails project I have model : class Panel < ActiveRecord::Base has_many :surveys scope :by_survey_name, ->(survey_name) { joins(:surveys).where('surveys.survey_name LIKE (?)', "%#{survey_name}%") } end And the question is how can I use this scope in activeadmin fiter? 回答1: Addd to model: def self.ransackable_scopes(_auth_object = nil) [:by_survey_name] end and then in resource: filter :by_survey_name, as: :string 来源: https://stackoverflow.com/questions/31694398/use-activerecord-scope-in