Rake only works once from rails

sorry this is rails related, but I think it’s more of a Rake thing

I’ve made a rake task that I’m running from my rails, and it works - but
only once. If I then restart the server (mongrel) it works again -
once.

I can simulate this in the console session as shown…

q = Rake::Task[“cache_sweeper”]
=> <Rake::Task cache_sweeper => []>

q.invoke
=>
[#Proc:[email protected]/script/../config/../config/../lib/tasks/cache.rake:4]

q = Rake::Task[“cache_sweeper”]
=> <Rake::Task cache_sweeper => []>

q.invoke
=> nil

… when q.invoke returns the “[#Proc:…” it has worked correctly, nil
means nothing happened.

Any one have insight to what is happening with rake?

Thank you,

On Mar 26, 2008, at 16:55 , Andy K. wrote:

cache.rake:4>]
Any one have insight to what is happening with rake?
It is doing it’s job. Rake runs tasks once by definition. It is a
build tool. That is what it is for.

Ryan D. wrote:

q.invoke
… when q.invoke returns the “[#Proc:…” it has worked correctly,
nil means nothing happened.

Any one have insight to what is happening with rake?

It is doing it’s job. Rake runs tasks once by definition. It is a build
tool. That is what it is for.

ah, so my usage is incorrect - that’s what I was suspecting

Thanks for confirming my suspicions

On Mar 28, 2008, at 11:26 , Andy K. wrote:

ah, so my usage is incorrect - that’s what I was suspecting

Thanks for confirming my suspicions

just change task to def and remove the do and you should be fine. keep
rake required to cheat and get fileutils and other handy utility
methods added.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs