Created
July 1, 2011 06:39
-
-
Save rdj/1057991 to your computer and use it in GitHub Desktop.
active_admin custom filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# config/initializers/active_admin.rb | |
require 'active_admin_custom_filter' | |
ActiveAdmin.setup do |config| | |
# ... | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# lib/active_admin_custom_filter.rb | |
module ActiveAdmin | |
class FilterFormBuilder | |
include ::ActionView::Helpers::OutputSafetyHelper | |
def filter_custom_input( method, options = {} ) | |
field_name = method | |
safe_join( | |
[ | |
label( field_name, I18n.t( 'active_admin.search_field', :field => options[:label] ) ), | |
text_field( field_name ) | |
], | |
"\n" | |
) | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# app/admin/resource.rb | |
ActiveAdmin.register Resource do | |
filter :first_name_or_last_name_contains, :as => :custom, :label => 'Name' | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The class seems to have changed in 1.0.0.pre. This works for me.