Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check hstore key changes in Rails

I have hstore column (email_subscribing) in model. And have strore_accessor

I want to check changes of one key from this store on after_update callback

store_accessor :email_subscribing, :common_users_list, :admins_list, :caretakers_list,                      :tenant_admins_list, :managers_list

after_update :update_mailchimp_subscriptions, if: :email_ep_updates_changed?

But get an error - undefined method `email_ep_updates_changed?'

What is the solution?

like image 929
a.kozubenko Avatar asked Dec 20 '25 04:12

a.kozubenko


1 Answers

I think that the answer that you're looking for can be found here in this previous post:

How to determine if any field in a model / nested model changed?

The method name email_ep_updates_changed? doesn't appear to exist but you should be able to accomplish what you're setting out to do via the post above. You just need to add the _changed? to the end of the attribute name of what it is that you're checking or use .changed? on the actual Model itself if you're not looking for a specific attribute.

like image 112
Stephen W Avatar answered Dec 21 '25 19:12

Stephen W