rake only works once from rails

A

Andy Koch

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"]
=> said:
=>
[# said:
q = Rake::Task["cache_sweeper"]
=> said:
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,
 
R

Ryan Davis

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"]
=> [#<Proc:0xb6d03444@./script/../config/../config/../lib/tasks/
cache.rake:4>]
q = Rake::Task["cache_sweeper"]
=> said:
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?

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

Andy Koch

Ryan said:
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"]
=> said:
=>
[# said:
q = Rake::Task["cache_sweeper"]
=> said:
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?

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
 
R

Ryan Davis

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top