簡體   English   中英

RailsAdmin hstore和自定義標簽

[英]RailsAdmin hstore and custom lable

無法同時配置hstore和自定義標簽

hstore的配置

模型

  store_accessor :list_of_hstore_keys

  rails_admin do
  # Show the string hstore fields
    User.stored_attributes[:options].each do |field|
      configure field
    end
  end

自定義標簽的配置(在初始化程序中)

config.model User do
  list do
    configure :orders_count do
      label 'Has orders'
    end
  end
end

並引發異常

FrozenError - can't modify frozen Array:

如果我刪除其中一種配置,則另一種效果很好。 但是我都需要。

也許有人知道我可以解決這個問題。

謝謝。

我的解決方案:

我將配置從模型移動到初始化RailsAdmin

結果/config/initializers/rails_admin.rb

config.model User do
  User.stored_attributes[:options].each do |field|
    configure field
  end

  list do
    configure :custom_field_from_method
    configure :orders_count do
      label 'Has orders'
    end
  end
end

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM