gpt4 book ai didi

ruby-on-rails - 使用 hstore 过滤 activeadmin

转载 作者:太空宇宙 更新时间:2023-11-03 17:25:01 25 4
gpt4 key购买 nike

我想在 hstore 中使用 activeadmin 过滤器:

在模型中,我有带有 Room 的柱设施。

我想这样做:

filter :amenities, :as => :select, :collection => proc {Room.all.map{|r| r.amenities} }

最佳答案

您可以只为 HStore 数据类型创建一个 Formtastic 自定义输入。如果您不希望 Hstore 值是可编辑的,这就足够了(您还可以使用 input_html_options 将输入字段设置为只读):

class HstoreInput < Formtastic::Inputs::StringInput

end

虽然这会在写入时破坏属性值。

关于ruby-on-rails - 使用 hstore 过滤 activeadmin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14605710/

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