How to filter IS NULL in ActiveAdmin?

前端 未结 5 765
迷失自我
迷失自我 2020-12-25 14:14

I\'ve a table with an integer column called \"map_id\", I want to add an activeadmin filter to filter if this column IS NULL or IS NOT NULL.

How could this be implem

5条回答
  •  旧时难觅i
    2020-12-25 15:01

    seems search_method doesn't work in recent rails version, here is another solution:

    add scope to your model:

      scope :field_blank, -> { where "field is null" }
      scope :field_not_blank, -> { where "field is not null" } 
    

    add to /app/admin/[YOUR MODEL]

       scope :field_blank
       scope :field_not_blank
    

    you will see buttons for these scopes appear (in top section, under model name, not in filter section)

提交回复
热议问题