Closed 42ae closed 9 years ago
I fixed it by monkey-patching the gem:
def self.from_json(str, parent = nil)
blocks = MultiJson.load(str.to_json, symbolize_keys: true)
blocks = blocks[:data] if blocks.is_a?(Hash)
blocks.map! { |block_obj| SirTrevorRails::Block.from_hash(block_obj, parent) }
new blocks
end
Can anyone confirm that this bug so I can commit the fix?
@liyali do you happen to be using a data type in your database that would return a hash instead of a string, such as a json column in postgres? The gem appears to assume a string based data type to serialize between.
@lsirivong correct, I am using a postgres json column type.
@liyali Thanks for reporting! I've committed something that should fix this. Try it out and let us know how it goes.
This appears to be still broken. I'm using the sir_trevor_rails, v 0.5.0b1 gem.
I am using a very simple scenario here, but when calling the
create
action of my controller, I get the following error:The
create
action was generated through scaffolding, my model does havesir_trevor_content :content
and my view is a simple text_area field:Note that the controller action parameters seem to be correct:
The error occurs on save (@page = Page.new(page_params) if @page.save). Any idea? Thanks!
using rails 4.1.6