attr_json: Very smooth models-within-models serialized to json in ActiveRecord

11 weergaven
Naar het eerste ongelezen bericht

jroc...@sciencehistory.org

ongelezen,
26 jun 2018, 15:14:5326-06-2018
aan Ruby on Rails: Talk
Hey, I wrote a gem that lets you have attributes in an ActiveRecord model serialize to keys in a json hash serialized to Json. It supports casting/typing just like AR, arrays, models-within-models, form builders (including treating models-within-arrays-and-models like you treat associations), dirty tracking on a per-attribute basis for json-serialized attributes, and some very basic querying support (also across models-within-models). 

It was possible, in surprisingly few lines of code and working so consistently with "normal" AR,  only cause of the awesome work sgriffin and others did on the Attributes API stuff, and other Rails "internal" APIs.  Rails gets a lot of complaints for it's architecture and legacy code (some deserved), but there's increasingly some really nice architecture in there to build off of. 

So, you, dear reader, may be interested:


Feedback of any sort very welcome. 

Jonathan


Allen beantwoorden
Auteur beantwoorden
Doorsturen
0 nieuwe berichten