How can I make active admin to show "Yes" and "No" instead of "true" and "false".
I tried to change in english locale but that doesn't work. I'm thinking of monkeypatching boolean classes, but this seems quite ugly.
Is there anything else I can do?
You might like to do something like this:
index do
id_column
column(:published) do |story|
story.published? ? status_tag( "yes", :ok ) : status_tag( "no" )
end
end
This will wrap the words "yes" and "no" in status tags which look rather good.
Try to use condition directly in active admin as below
column :column_name do|object|
object.column_name? ? 'Yes' : 'No'
end
Here, this works, it gives you a tick and cross, but appears to be easy to modify.
https://gist.github.com/2574969
You'll need to restart your rails server for this to work, as it modifies the active_admin.rb initialiser.
Of course it creates a class, which is what you want to avoid, but in the absence of anything else, this does work.
Its very simple,
Suppose your Boolean field name is active,
create a method named status like
def status
self.active ? "Yes" : "No"
end
Use the status as a normal field in active admin show or index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With