attr_json
attr_json copied to clipboard
Serialized json-hash-backed ActiveRecord attributes, super smooth
``` class TestModel include AttrJson::Model attr_json :test, :string end foo = TestModel.new(test: 'foo') bar = foo.dup bar.test = 'bar' foo.test #=> bar ``` Same behavior with `clone` and `deep_dup`.
There are already some methods in the `*attributes=` methods created for handling form-submitted values that ignore empty strings. If using a repeatable AttrJson::Model, submitting a hash with _entirely_ blank values...
at least if you included AttrJson::NestedAttributes. Working with it, it's a pain to have to do this manually, and I can't think of any reason you _wouldn't_ want it (if...
ActiveRecord.time_zone_aware_attributes is `true` by default, and what it does is turn all your AR date/time attributes into magical [ActiveSupport::TimeWithZone](http://api.rubyonrails.org/classes/ActiveSupport/TimeWithZone.html) objects that (basically) have the current `Time.zone` zone attached to them....
If everything in this ticket had been here when we started (Back in Rails 4.2!!!) -- this gem would be much smaller, or maybe wouldn't need to exist? We may...
### Context I have a jsonb attribute on my model that contains an array of dates: ``` class MyModel < ApplicationRecord include AttrJson::Record attr_json :recurrence_dates, :date, array: true, default: [],...
Thank you for this very useful and well documented gem. Does it work with rails enums? I tried: ```ruby class UserRegistration include AttrJson::Record attr_json :first_name, :string attr_json :last_name, :string attr_json...
**(note from maintainer: There are a variety of things that could cause a NoMethodError. If you have such an error but don't know why, please file a separate Issue or,...
originally from @guilhermegazzinelli ----- Hi Jonathan, I had the same issue, but with custom types. The error is as follows: `*** ActiveModel::MissingAttributeError Exception: missing attribute: settings` In another investigation I...
There is a new normalization feature coming in Rails 7.1. https://github.com/rails/rails/pull/43945 In attr_json 2.0, becuase of changes to sync better with ActiveRecord attribuets, i predict it should _just work_ for...