The project is in a healthy, maintained state
Using this gem, ActiveRecord's JSON attribute is deserialized into HashWithIndifferentAccess.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
 Dependencies

Development

Runtime

>= 5.2.0
 Project Readme

Gem Version

ActiveRecord Accessible Json

Using this gem, ActiveRecord JSON typed attribute is deserialized into HashWithIndifferentAccess if possible.

Example

# Both author and tags are JSON typed columns.
Post.create(author: { 'name': 'yamat47', 'age': 27 }, tags: %w[Rails TDD])

post = Post.last
post.author.class #=> ActiveSupport::HashWithIndifferentAccess
post.author['name'] #=> 'yamat47'
post.author['name'] == post.author[:name] #=> true

post.author = { name: 'Andy', age: 30 }
post.author.class #=> ActiveSupport::HashWithIndifferentAccess
post.author['name'] #=> 'Andy'
post.author['name'] == post.author[:name] #=> true

# If attribute's value is not changeable into HashWithIndifferentAccess,
# this gem does nothing.
post.tags.class #=> Array

Version Compatibility

Rails 5.2 Rails 6.0 Rails 6.1 Rails head
Ruby 2.5
Ruby 2.6
Ruby 2.7
Ruby 3.0
Ruby head

Version compatibility is checked everyday on CI.

Installation

Add this line to your Rails application's Gemfile:

gem 'activerecord_accessible_json'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activerecord_accessible_json

Release

  1. Check if CI is passed on main.
  2. Decide next versioning and update version.rb.
  3. bundle install.
  4. Commit these changes with happy message (like "Release v0.2.0 🎉").
  5. ghch --format=markdown --next-version={{ NEXT_VERSION }} to generate changelog.
  6. Create new release.
  7. bundle exec rake build.
  8. bundle exec rake release.

License

The gem is available as open source under the terms of the MIT License.