I'm a React, Javascript & Rails full-stack Software Engineer. I have been working remotely for the past two years in a remote village. Before joining as a Software Engineer I founded kwiq - a hyperlocal delivery startup to deliver things in remote villages.
2 minute read
In Rails, to reset associations
and clear the cache for a specific association, we can use the reset method.
This method reloads the association
and clears any cached data related to it.
Before
If we observe the above example, we reset associations
and cleared the cache on has_many associations. But for singular associations, we can not reset and clear the cache.
Before Rails 7.1, to reset the associations
and clear the cache, we can use the reload association method.
But there is no reset method on singular associations.