Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Raise a descriptive error when a store column is misconfigured
If a developer has neglected to use a structured column type (hstore or json) or to declare a serializer with `ActiveRecord.store`: ```ruby class User < ActiveRecord::Base store_accessor :settings, :notifications end ``` then a `ConfigurationError` will now be raised with a descriptive error message when the accessor is read or written: ```ruby puts user.notifications # ActiveRecord::ConfigurationError: the column 'settings' has not # been configured as a store. Please make sure the column is # declared serializable via 'ActiveRecord.store' or, if your # database supports it, use a structured column type like hstore or # json. ``` Previously, in this situation, a `NoMethodError` was raised when the accessor was read or written: ```ruby puts user.notifications # NoMethodError: undefined method `accessor' for an instance of ActiveRecord::Type::Text ``` Raising a descriptive exception should help developers understand more quickly what's wrong and how to fix it. Closes rails#51699
- Loading branch information