Open migu0 opened 11 years ago
+1 Is there a workaround / fix available ?
I think the best solution would be to create a custom field type. Also, you can take a look at this example of a field type for serialized column: https://github.com/bbenezech/blog_admin/blob/1c06298f8330cdbbfba411e3b174f8fca04e7f6d/app/models/blog/post.rb https://github.com/bbenezech/blog_admin/blob/master/lib/rails_admin/metadata.rb
Did that solution work for you? I don t see my model at all as soon as I have the serialize on a Hstore object... but then on a Hash it shows but no field showing ever :(
Actually I removed it and just made the field visible and everything seems to work without any patch.. Now updating the field is a bit tricky as I need to remove the {} around the hash but seems to work partially now.
Saving seems to perform some escaping. Any easy way to prevent it or create my own saving? (maybe like turning the string into a Hash and save it or something alike)
before save {"a"=>"[1, 2, 3]"}
after save on rails_admin {"{\"a\""=>"[1, 2, 3]"}
I was able to get support for hstore working by using the Rails 4 store_accessor
in my model and listing the fields in the Rails admin config for my model. It's a simple solution.
class Organization < ActiveRecord::Base
store_accessor :modules, :internal, :external, :default => 'no'
rails_admin do
Organization.stored_attributes[:modules].each do |field|
configure field
end
end
end
Awesome, do you want to post it here: http://stackoverflow.com/questions/19235247/railsadmin-hstore-columns-dont-show ?
I answer the SO question. I also put my solution in a demo app available on Github.
The demo app includes a module called StoreBoolean that adds support for boolean attributes stored in an hstore field. I'd like some comments on that module.
Awesome gem, thanks for your work.
I have an hstore column (PostgreSQL datatype, supported by default in Rails 4). The column doesn't show up in RailsAdmin. I guess it's not supported? Is there a workaround?