active_record.cr icon indicating copy to clipboard operation
active_record.cr copied to clipboard

Support JSON.mapping better

Open waterlink opened this issue 8 years ago • 1 comments

Currently, JSON.mapping overrides .new({ ... => ... }) constructor with its own.

Workaround for now is to do:

class Post < ActiveRecord::Model
  # ...

  def initialize(h : Hash)
    super(h)
  end

  JSON.mapping({ ... })
end

waterlink avatar Mar 30 '16 09:03 waterlink

This actually will still not work. Since JSON.mapping expects mapped fields to be in @<field_name>, but they are in @typed_fields[<field type>][<field name>] at the moment.

waterlink avatar Apr 02 '16 20:04 waterlink