用hstore过滤activeadmin [英] Filter activeadmin with hstore

查看:54
本文介绍了用hstore过滤activeadmin的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I would like to use activeadmin filters with hstore:

在模型中,我的Room具有列设施。

In model I have got column amenities with Room.

我想这样做:


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

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


推荐答案

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

You could just create a Formtastic custom input for the HStore Datatype. If you don't want the Hstore values to be editable this should be sufficient (you could additionally set the the input field to read-only with input_html_options):

class HstoreInput < Formtastic::Inputs::StringInput

end

这将破坏属性值。

这篇关于用hstore过滤activeadmin的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆