Created
February 5, 2014 16:47
-
-
Save traviskroberts/8827994 to your computer and use it in GitHub Desktop.
Custom filter for ActiveAdmin.
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
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 |
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
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