Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd 'not' options to filter #3662
Comments
|
+1 |
|
@jostster , ActiveAdmin.register Order do
filter :user_id_not_eq, label: 'Except User', as: :select, collection: ->{ User.all }
end |
|
string search is still possible
one issue is there is no aliases to use it like not_starts_with, not_ends_with ... and not translations for this. |
|
Using version 1.0.0.pre of ActiveAdmin, I was able to implement 'Does Not Contain' to a string filter with a few small workarounds, guided mostly by @Fivell's last comment. ActiveAdmin.register User do
filter :username, as: :string, filters: [:contains, :equals, :starts_with, :ends_with, :not_contains]
endNote that in order to include the default options in the drop-down, they needed to be included, and In my en:
active_admin:
filters:
predicates:
not_contains: "Does Not Contain"With these in place, filtering by 'Does Not Contain' works as expected. Edit: This does not work as expected. It will simply return no results. |
|
@ryanflach I managed to get this working by using |
|
@ghilead and @ryanflach thanks guys it works like a charm. It would be nice to add these across the board for any string. This should really be a PR, such a great feature. |

Formed in 2009, the Archive Team (not to be confused with the archive.org Archive-It Team) is a rogue archivist collective dedicated to saving copies of rapidly dying or deleted websites for the sake of history and digital heritage. The group is 100% composed of volunteers and interested parties, and has expanded into a large amount of related projects for saving online and digital history.

There should be 'does not contain' or 'does not have' option in the filters. I have a :through relationship and want to be able to filter results based on entries that do not have a specific relationship. This should be togglable so that the admin can either use it to find records that DOES contain the relation or DOES NOT contain the relation. Also being able to add this to strings would be needed so admins can find users or fields that were left empty. A good filter system that has these options that can be used used to see what I am talking about is keystonejs.