Delete Cached Models in CakePHP
This seems to bite me in the ass more often than not but any time you add a new model or adjust your associations, be sure to delete the cached ones from the /app/tmp/ folder. I'll get inexplicable errors about missing models and it always takes me a couple minutes to figure it out.
Conversation
If you've got cake running in development mode, it should check the db for updates to the table quite often. (That's that DESC *table name* that you see in the query output)
Walker: yeah, it's usually pretty good on a dev server. I tend to notice it more when I push stuff live and suddenly nothing loads.
I have gotten into the habit of emptying the cache after any update to a live server, granted there are some situations where this might be a problem but for most of my clients' sites the cache is more of a convenience than a necessity.
It's always fun wasting 5-6 minutes trying to figure out why an update failed, realizing the code was right all along.
Haha, ya this happens a lot. You keep wondering what's wrong with the code? Why isn't the update showing up properly? Then you realize it's something silly like forgetting to delete the cache.
Yep -- that's always a "gotcha" for me. Enough so that I've considered putting in a "clear model cache" button in the Admin area of CakePHP sites I work on... even just to save a few seconds clearing them via the command line. It's even more of a confusing gotcha because in debug mode things work smoothly (like Walker said already).
My usual trick to fix this is to enable debugging then disable it again, seems to clear the model caching.
Especially in models and persistent
$ rm -f /app/tmp/cache/models/cake_model_*
$ rm -f /app/tmp/cache/persistent/cake_core_*