Skip to content

Instantly share code, notes, and snippets.

@jameslafa
Forked from fred/active_admin.rb
Created July 29, 2013 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameslafa/6104482 to your computer and use it in GitHub Desktop.
Save jameslafa/6104482 to your computer and use it in GitHub Desktop.
Show pretty booleans in active_admin
# It extends activeadmin to show pretty boolean values
#
# config/initializers/active_admin.rb
module ActiveAdmin
module Views
class TableFor
def bool_column(attribute)
column(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe }
end
end
class AttributesTable
def bool_row(attribute)
row(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe }
end
end
end
end
# example
# app/admin/user.rb
ActiveAdmin.register User do
index do
column :name
column :email
bool_column :admin
end
show do
attributes_table do
row :name
row :email
bool_row :admin
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment