{"repo":"jrochkind/attr_json","free":true,"listed":false,"github":"https://github.com/jrochkind/attr_json","clone":"git clone https://github.com/jrochkind/attr_json.git","description":"Serialized json-hash-backed ActiveRecord attributes, super smooth","language":"Ruby","stars":607,"topics":["activerecord","jsonb","postgresql"],"license":"MIT","category":"databases-storage","readme_excerpt":"AttrJson ActiveRecord attributes stored serialized in a json column, super smooth. For Rails 6.0.x through 7.0.x. Ruby 2.7+. Typed and cast like Active Record. Supporting nested models, dirty tracking, some querying (with postgres jsonb contains), and working smoothy with form builders. Use your database as a typed object store via ActiveRecord, in the same models right next to ordinary ActiveRecord column-backed attributes and associations. Your json-serialized attr json attributes use as much of the existing ActiveRecord architecture as we can. Why might you want or not want this? Developed for postgres, but most features should work with MySQL json columns too, although has not yet been tested with MySQL. Basic Use What will get serialized to your json attributes column will look like: These attributes have type-casting behavior very much like ordinary ActiveRecord values. You can use ordinary ActiveRecord validation methods with attr json attributes. All the attr json attributes are serialized to json as keys in a hash, in a database jsonb/json column. By default, in a column json attributes . If you look at model.json attributes , you'll see values already cast to their ruby representations. To see JSON representations, we can use Rails \\ \\ before type cast methods, \\ \\-in database and [\\ \\ for database] methods (Rails 7.0+ only). These methods can all be called on the container json attributes json hash attribute (generally showing serialized JSON to string), or any ind","default_branch":null,"files":null,"tree":[],"storefront":"/r/jrochkind","claimed":false,"request_supported":{"post":"https://gitbuyer.com/r/jrochkind/attr_json/request-supported","requests":0},"note":"indexed from public GitHub; nothing is for sale on this page. Clone it from GitHub. Paid listings live at /search."}