rails_admin更改布尔值默认图标true和false而不是string' true'并且' false'

时间:2017-05-25 05:24:07

标签: ruby-on-rails ruby-on-rails-4 rails-admin rails-administrate

enter image description here

我确实在一个带有布尔字段的模型上创建了

rails g model saas reserved_seat:boolean

当我添加新记录时,它将仅显示✓,✘和 -

enter image description here

相反,我需要重视显示' true '或' false '也不是 ON '或者' OFF'在字符串

2 个答案:

答案 0 :(得分:1)

请参阅此处的文档wiki

RailsAdmin.config do |config|
  config.model 'Saas' do
    edit do
      field :reserved_seat, :string
    end
  end
end

答案 1 :(得分:0)

我做的是:

field :reserved_seat do
   pretty_value do
    if bindings[:object].reserved_seat==true
        %{<span style="color:blank;" >ON</span>}.html_safe
      else
        %{<span style="color:blank;" >OFF</span>}.html_safe
    end
  end
 end