Example of using hstore fields in Rails Admin
If you are using an hstore field on your model to store a hash of attributes and you want to see the attributes in Rails Admin, follow these steps.
The hstore type requires PostgreSQL or another database that supports hstore.
Add store_accessor :customizations, :default_folder, :last_search
to
your model
(Optional) Hstore stores attributes as strings. If you want to store
some boolean attributes in a hstore, you can use the StoreBoolean
module.
extend StoreBoolean
store_accessor_boolean :preferences, :send_emails, :show_welcome, :default => false
rails_admin do
# Show the string hstore fields
User.stored_attributes[:customizations].each do |field|
configure field, :text
end
end
rails_admin do
User.stored_attributes[:preferences].each do |field|
configure field, :boolean
end
end
The boolean attributes are implemented in StoreBoolean. If you want to discuss the implementation in there, open an issue.