| joelmichael | oh wait |
| sheldonh | Newhydra: since you can't instantiate your cache sweeper, and expire_fragment is an actioncontroller method, so it's not available in a runner |
| joelmichael | i see what you're saying |
| azta | joelmichael: validates_presense_of :foo_id and validates_associated :foo |
| joelmichael | thats interesting |
| azta | joelmichael: I can just say .foo_id = 999999 and its valid?, even though theres no Foo with that id |
| Newhydra | sheldonh: ApplicationController.expire_all_fragments // def self.expire_all_fragments <do stuff> end |
| joelmichael | yeah, actually, validates_associated is something else. |
| biku | pastie |
| sheldonh | Newhydra: but expire_fragment is an instance method, not a class method ? |
| joelmichael | to my knowledge, there might not be a way to validate like you want |
| Newhydra | only if you think small |
| joelmichael | (automatically) |
| Newhydra | ;) |
| azta | shame, seems like something that any create/update action that has some kind of relationship would need |
| joelmichael | which is strange because you'd think it'd be a default validator |
| azta | yeah |
| Newhydra | sheldonh: expire_fragment is a method in the Caching module found in actionpack |
| joelmichael | i think it can be problematic when it comes to the order of saving hmm |
| azta | joelmichael: all it needs is a Foo.exists?(), but still |
| sheldonh | Newhydra: right. and it relies on aspects of actioncontroller, such as url_for |
| Newhydra | right, and script/runner loads your rails env, and you're calling the method on a controller therefore, the method has url_for available to it |
| greenjenny | Does anyone here use Locomotive on the Mac? |
| Newhydra | you just need to come up with a way to call expire_whatever from a class scope...which you can do, by calling it on the Caching module or by looking at that and seeing if you already have something similar |
| sheldonh | Newhydra: i'm... i'm calling the method on a controller? are you suggesting i instantiate a controller in the runner script? |
| Newhydra | no, I'm suggesting you do SomeController.expire_cache_stuff |
| sheldonh | Newhydra: and somehow arrange that this new class method have access to instance methods in the Caching module? |
| Newhydra | yep |
| sheldonh | Newhydra: i'm guessing you' |
| Newhydra | as far as I can tell from looking at it there's no reason it's in the instance scope |
| sheldonh | Newhydra: i'm guessing you haven't tried this yourself, because the Caching code has its fingers pretty deep in instance attributes of the controller |
| Newhydra | I have and it worked just fine...I replaced fragment_cache_key while I was at it because the original one didn't do what I wanted (it used the domain as part of the cache key) |
| sheldonh | Newhydra: hmmm, i seeeeeeee. fragment_cache_store is a cattr_reader :) :) :) |