Last active
August 29, 2015 14:16
-
-
Save shivanibhanwal/4bbf63b32cbea81d359e to your computer and use it in GitHub Desktop.
ActiveAdmin View TableFor and AttributesTable class customization
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
# Add this code to a new file and you can put it under app/admin/lib folder or else config/initializer/actice_admin.rb | |
module ActiveAdmin | |
module Views | |
class TableFor | |
def html_column(attribute) | |
column(attribute){ |model| model[attribute].html_safe } | |
end | |
def bool_column(attribute) | |
column(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe } | |
end | |
end | |
class AttributesTable | |
def html_row(attribute) | |
row(attribute){ |model| model[attribute].html_safe } | |
end | |
def bool_row(attribute) | |
row(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe } | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment