Reputation: 2117
I want to show in objects list the icon 'active.ico' if created_at<1.day.ago else
show 'passive.ico'.How would I do that?
RailsAdmin.config do |config|
config.model Player do
list do
field :created_at do # (1)
//if created_at<1.day show 'active.ico'
//else show 'passive.ico'
end
end
end
end
Upvotes: 0
Views: 995
Reputation: 1510
Use pretty_value
:
list do
field :created_at do
pretty_value do
# result from here will be passed to a view
if created_at = bindings[:object].try(:created_at)
if created_at < 1.day
image_tag("active.ico") # <img alt="Icon" src="/assets/active.ico" />
else
image_tag("passive.ico") # <img alt="Icon" src="/assets/passive.ico" />
end
end
end
end
end
Upvotes: 2