assignable_values icon indicating copy to clipboard operation
assignable_values copied to clipboard

Add support for Rails store accessor attributes

Open brunosedler opened this issue 7 months ago • 0 comments

It would be nice, if assignable_values would fully support Rails store accessor attributes. They have been around for quite a while now, and and are mostly quite pleasant to work with. If assignable_values would also support them, it would further enhance the usage of them.

Most of the assignable_values functionality already seems to work fine enough for store accessor attributes out of the box, but I came across at least one issue. The allow_blank option does not work for store accessor attributes on update. I assume, this has to do with the feature of always allowing the value that's already saved in the database and the check for the value in the database, that is performed to achieve this.

Now, since store attributes do not have an own database column, this check will always return nil and therefore always allow nil-values when validating the attribute.

As store attribute are its own kind of attribute (like belongs_to relations), they should probably be handled in an own restriction class, like AssignableValues::ActiveRecord::Restriction::StoreAttribute to explicitly handle all peculiarities of store attributes.

brunosedler avatar Jul 11 '24 13:07 brunosedler