#rubyonrails - Sun 22 Apr 2007 between 18:50 and 19:00



joelmichaeloh wait
sheldonhNewhydra: since you can't instantiate your cache sweeper, and expire_fragment is an actioncontroller method, so it's not available in a runner
joelmichaeli see what you're saying
aztajoelmichael: validates_presense_of :foo_id and validates_associated :foo
joelmichaelthats interesting
aztajoelmichael: I can just say .foo_id = 999999 and its valid?, even though theres no Foo with that id
Newhydrasheldonh: ApplicationController.expire_all_fragments // def self.expire_all_fragments <do stuff> end
joelmichaelyeah, actually, validates_associated is something else.
bikupastie
sheldonhNewhydra: but expire_fragment is an instance method, not a class method
?
joelmichaelto my knowledge, there might not be a way to validate like you want
Newhydraonly if you think small
joelmichael(automatically)
Newhydra;)
aztashame, seems like something that any create/update action that has some kind of relationship would need
joelmichaelwhich is strange because you'd think it'd be a default validator
aztayeah
Newhydrasheldonh: expire_fragment is a method in the Caching module found in actionpack
joelmichaeli think it can be problematic when it comes to the order of saving
hmm
aztajoelmichael: all it needs is a Foo.exists?(), but still
sheldonhNewhydra: right. and it relies on aspects of actioncontroller, such as url_for
Newhydraright, 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
greenjennyDoes anyone here use Locomotive on the Mac?
Newhydrayou 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
sheldonhNewhydra: i'm... i'm calling the method on a controller? are you suggesting i instantiate a controller in the runner script?
Newhydrano, I'm suggesting you do SomeController.expire_cache_stuff
sheldonhNewhydra: and somehow arrange that this new class method have access to instance methods in the Caching module?
Newhydrayep
sheldonhNewhydra: i'm guessing you'
Newhydraas far as I can tell from looking at it there's no reason it's in the instance scope
sheldonhNewhydra: i'm guessing you haven't tried this yourself, because the Caching code has its fingers pretty deep in instance attributes of the controller
NewhydraI 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)
sheldonhNewhydra: hmmm, i seeeeeeee. fragment_cache_store is a cattr_reader :) :) :)

Page: 2 9 16 23 30 37 44 51 58 65 

IrcArchive