How to: Tracking Dirty State

trevorturk edited this page Jun 9, 2011 · 1 revision
Clone this wiki locally

If you want to track the "dirty?" state of the upload column you can check the state of the cache.

@user.avatar.cached?.present? # means dirty?

In this example, a column is said to be dirty if it has been changed but not yet saved to persistence. In our case a file was uploaded (cached) but not yet "saved" to configured storage (filesystem, s3 etc)

You could also be using ActiveRecord's dirty tracking on the column you mount on.