Suggestion for #store_accessor to also define query and _was methods

Dear Rails Core mailing list,

I would like to propose some additions to the #store_accessor method, so that also defines query and _was methods.

Example usage:

class User < ActiveRecord::Base

store :settings, accessors: [ :color, :homepage ], coder: JSON


u = User.create(color: ‘black’, homepage: ‘’)

u.color? # => true

u.color = ‘white’

u.color_was # => “black”

I can submit a PR if you support the change.


Do we have enough use cases to support adding the _was method?

I don’t think we need to have specific cases to justify _was. The purpose, AFAIK, with the store accessors is to be transparent about whether they’re full columns or not. For this reason, they should accommodate the same methods, such as changed? and the _was methods to accurately reflect the same API that attributes have.