I would like to use activeadmin filters with hstore:
In model I have got column amenities with Room.
I would like to do sth like this:
fil
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
This will break the attribute values on write though.
With latest activeadmin
(which uses ransack instead of meta_search) it's possible to define a custom ransacker
for hstore field in a model:
class Room < ActiveRecord::Base
store_accessor :options, :amenities
ransacker :amenities do |parent|
Arel::Nodes::InfixOperation.new('->', parent.table[:options], 'amenities')
end
end
Then it can be used in activeadmin
for filtering:
ActiveAdmin.register Room do
filter :amenities_eq, label: 'Amenities', as: :select # ...
end