Skip to content

Instantly share code, notes, and snippets.

@traviskroberts
Created February 5, 2014 16:47
Show Gist options
  • Save traviskroberts/8827994 to your computer and use it in GitHub Desktop.
Save traviskroberts/8827994 to your computer and use it in GitHub Desktop.
Custom filter for ActiveAdmin.
ActiveAdmin.register User do
index do
column :id
column :full_name, sortable: :last_name
column :status
default_actions
end
filter :first_name
filter :last_name
filter :status_name, label: "Status", as: :select, collection: [:active, :inactive, :invited]
form do |f|
f.semantic_errors *f.object.errors.keys
f.inputs do
f.input :first_name
f.input :last_name
f.input :status
end
f.actions
end
# Show page
show title: proc { "#{@user.full_name}" } do |user|
attributes_table do
row :id
row :first_name
row :last_name
row :email
end
end
end
class User < ActiveRecord::Base
search_methods :status_name
scope :status_name, ->(status) { where("status = ?", status) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment