Ruby on rails Rails\u admin在列表中显示图像图标
我想在对象列表中显示图标“active.ico”,如果在使用Ruby on rails Rails\u admin在列表中显示图像图标,ruby-on-rails,rails-admin,Ruby On Rails,Rails Admin,我想在对象列表中显示图标“active.ico”,如果在使用pretty\u值创建: 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_
pretty\u值创建:
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
列出要做的事情
字段:在do处创建
很有价值吗
#此处的结果将传递给视图
如果已创建\u at=bindings[:object]。请尝试(:已创建\u at)
如果在<1.5天时创建
图像标签(“active.ico”)#
其他的
图像标签(“被动式.ico”)#
结束
结束
结束
结束
结束
然后您需要根据需要调整代码示例。例如,将其替换为image\u标签
。
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