I'm storing my client settings in a JSON object and am trying to encrypt that object using the Lockbox gem.
Here's the section from my model:
store :settings, accessors: %i[currency]
encrypts :settings
When I load up a client model (with an empty settings field) and try and save the currency like this:
client=Client.first
client.currency="USD"
client.save
Nothing is saved and both client.settings and client.currency return nil. If I add a random item to the hash, for example:
client=Client.first
client.settings={:test=>"test"}
client.currency="USD"
client.save
This saves as expected and client.currency returns "USD" and client.settings returns {:test=>"test", :currency=>"USD"}
Why can I not set the currency when the settings field is empty?