我在一个数据库表中有一个值,它有像#ffffff 这样的颜色代码,我希望在active_admin 中用简单的单词显示这些值。
例如对于#ffffff,words 中的值是“white”。在普通的 Rails 代码中更简单,但在使用 DSL 的活动管理员中,我很困惑。
我尝试了一个基本配置:
row("Paper Color") { order.colorpaper }
从 order.colorpaper 模型中得出 #ffffff 的值(如果我在前端选择了“白色”)。
但是在我的 prints.rb 模型中,也有一个列表,连接在 MY_COLORS 中,通常在正常的 rails 配置中使用 Prints::MY_COLORS 调用。
MY_COLORS = {
white: '#ffffff',
green: '#7bd148',
bold_blue: '#5484ed',
blue: '#a4bdfc',
turquoise: '#46d6db',
light_green: '#7ae7bf',
bold_green: '#51b749',
yellow: '#fbd75b',
orange: '#ffb878',
red: '#ff887c',
bold_red: '#dc2127',
purple: '#dbadff',
gray: '#e1e1e1'
}