:show do attri-6ren">
gpt4 book ai didi

ruby-on-rails - Rails 3 事件管理员。有人知道如何设置正常、警告和错误颜色吗?

转载 作者:太空宇宙 更新时间:2023-11-03 16:08:39 24 4
gpt4 key购买 nike

我正在创建一个应该显示未结余额的应用程序,如果客户有余额,它应该以红色背景显示。

所以我有这个

sidebar "Account Balance", :only => :show do
attributes_table_for invoice do
row("Invoice Total") {number_to_currency invoice.total}
row("Amount Paid") {number_to_currency invoice.amount_paid}
row("Open Balance") {number_to_currency invoice.open_balance}
end
end

我正在尝试添加颜色,但在 activeadmin 文档中找不到如何添加颜色。

虽然有一个教程,有点解释如何添加颜色(使用 ActiveAdmin css [如果 ActiveAdmin 中有我可以使用的东西,我不想弄乱 CSS])但我还没有能够在我的应用程序上实现它。 http://net.tutsplus.com/tutorials/ruby/create-beautiful-administration-interfaces-with-active-admin/

有人知道吗?

最佳答案

如果我没有误读文档,这应该有效:

sidebar "Account Balance", :only => :show do
attributes_table_for invoice do
row("Invoice Total") { content_tag(:span, number_to_currency(invoice.total), :class => invoide.total < 0 ? "negative" : "positive" }
end
end

你最终会得到一个 <span class="negative">-15$</span>然后你可以通过 CSS 设置样式

关于ruby-on-rails - Rails 3 事件管理员。有人知道如何设置正常、警告和错误颜色吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8659174/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com