StoreModel alternatives and similar gems
Based on the "ORM/ODM Extensions" category.
Alternatively, view StoreModel alternatives based on common mentions on social networks and blogs.
-
ActsAsTaggableOn
A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts. -
ActiveRecord Import
A library for bulk insertion of data into your database using ActiveRecord. -
Audited
Audited (formerly acts_as_audited) is an ORM extension that logs all changes to your Rails models. -
Apartment
Database multi-tenancy for Rack (and Rails) applications -
PublicActivity
Easy activity tracking for models - similar to Github's Public Activity -
Awesome Nested Set
An awesome replacement for acts_as_nested_set and better_nested_set. -
Closure Tree
Easily and efficiently make your ActiveRecord models support hierarchies -
Enumerize
Enumerated attributes with I18n and ActiveRecord/Mongoid support -
Ruby JSON Schema Validator
Ruby JSON Schema Validator -
ActiveRecord Reputation System
An Active Record Reputation System for Rails -
Acts As Tennant
Easy multi-tenancy for Rails in a shared database setup. -
dry-validation
Validation library with type-safe schemas and rules -
ActsAsParanoid
ActiveRecord plugin allowing you to hide and restore records without actually deleting them. -
acts_as_follower
A Gem to add Follow functionality for models -
ranked-model
An acts_as_sortable/acts_as_list replacement built for Rails 4, 5 and 6 -
ActiveRecordExtended
Adds additional postgres functionality to an ActiveRecord / Rails application -
Acts As Commentable
The ActiveRecord acts_as_commentable plugin -
Acts As Commentable with Threading
Similar to acts_as_commentable; however, utilizes awesome_nested_set to provide threaded comments -
Rails PG Extras
Rails PostgreSQL database performance insights. Locks, index usage, buffer cache hit ratios, vacuum stats and more. -
Unread
Handle unread records and mark them as read with Ruby on Rails -
activerecord-multi-tenant
Rails/ActiveRecord support for distributed multi-tenant databases like Postgres+Citus -
ActsAsTree
ActsAsTree -- Extends ActiveRecord to add simple support for organizing items into parent–children relationships. -
mongoid-history
Multi-user non-linear history tracking, auditing, undo, redo for mongoid. -
activerecord_json_validator
🔩 ActiveRecord::JSONValidator makes it easy to validate JSON attributes against a JSON schema. -
ArLazyPreload
Lazy loading associations for the ActiveRecord models -
ActiveImporter
Define importers that load tabular data from spreadsheets or CSV files into any ActiveRecord-like ORM. -
Mongoid Tree
A tree structure for Mongoid documents using the materialized path pattern -
arel-helpers
Useful tools to help construct database queries with ActiveRecord and Arel. -
ActiveValidators
Collection of ActiveModel/ActiveRecord validators -
PermenantRecords
Rails Plugin - soft-delete your ActiveRecord records. It's like an explicit version of ActsAsParanoid -
data_miner
Download, unpack from a ZIP/TAR/GZ/BZ2 archive, parse, correct, convert units and import Google Spreadsheets, XLS, ODS, XML, CSV, HTML, etc. into your ActiveRecord models. Uses RemoteTable gem internally. -
ActiveRecord::Turntable
ActiveRecord Sharding Plugin -
Espinita
Audit activerecord models like a boss (and works with rails 4!) -
mini_record
ActiveRecord meets DataMapper, with MiniRecord you are be able to write schema inside your models.
Clean code begins in your IDE with SonarLint
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of StoreModel or a related project?
README
StoreModel

StoreModel gem allows you to wrap JSON-backed DB columns with ActiveModel-like classes.
- 💪 Powered with Attributes API. You can use a number of familiar types or write your own
- 🔧 Works like ActiveModel. Validations, enums and nested attributes work very similar to APIs provided by Rails
- 1️⃣ Follows single responsibility principle. Keep the logic around the data stored in a JSON column separated from the model
- 👷♂️ Born in production.
class Configuration
include StoreModel::Model
attribute :model, :string
enum :status, %i[active archived], default: :active
validates :model, :status, presence: true
end
class Product < ApplicationRecord
attribute :configuration, Configuration.to_type
end
Why should I wrap my JSON columns?
Imagine that you have a model Product
with a jsonb
column called configuration
. This is how you likely gonna work with this column:
product = Product.find(params[:id])
if product.configuration["model"] == "spaceship"
product.configuration["color"] = "red"
end
product.save
This approach works fine when you don't have a lot of keys with logic around them and just read the data. However, when you start working with that data more intensively–you may find the code a bit verbose and error-prone.
For instance, try to find a way to validate :model
value to be required. Despite of the fact, that you'll have to write this validation by hand, it violates the single-responsibility principle: why parent model (Product
) should know about the logic related to a child (Configuration
)?
📖 Read more about the motivation in the Wrapping JSON-based ActiveRecord attributes with classes post
Getting started
Start with creating a class for representing the hash as an object:
class Configuration
include StoreModel::Model
attribute :model, :string
attribute :color, :string
end
Attributes should be defined using Rails Attributes API. There is a number of types available out of the box, and you can always extend the type system.
Register the field in the ActiveRecord model class:
class Product < ApplicationRecord
attribute :configuration, Configuration.to_type
end
When you're done, the initial snippet could be rewritten in the following way:
product = Product.find(params[:id])
if product.configuration.model == "spaceship"
product.configuration.color = "red"
end
product.save
Usage note: Rails and assigning Arrays/Hashes to records
- Assigned attributes must be a String, Hash, Array of Hashes, or StoreModel. For example, if the attributes are coming from a controller, be sure to convert any ActionController::Parameters as needed.
- Any changes made to a StoreModel instance requires the attribute be re-assigned; Rails doesn't track mutations of objects. For example:
self.my_stored_models = my_stored_models.map(&:as_json)
Documentation
- [Installation](./docs/installation.md)
- StoreModel::Model API:
- [Validations](./docs/validations.md)
- [Enums](./docs/enums.md)
- [Nested models](./docs/nested_models.md)
- [Unknown attributes](./docs/unknown_attributes.md)
- [Array of stored models](./docs/array_of_stored_models.md)
- [One of](./docs/one_of.md)
- [Alternatives](./docs/alternatives.md)
- [Defining custom types](./docs/defining_custom_types.md)
Credits
Initially sponsored by Evil Martians.
License
The gem is available as open source under the terms of the MIT License.
*Note that all licence references and agreements mentioned in the StoreModel README section above
are relevant to that project's source code only.