[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

rake only works once from rails

andy

3/26/2008 11:56:00 PM

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:0xb6d03444@./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,


4 Answers

Ryan Davis

3/27/2008 11:57:00 PM

0


On Mar 26, 2008, at 16:55 , Andy Koch wrote:
> 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:0xb6d03444@./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?

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



andy

3/28/2008 6:27:00 PM

0

Ryan Davis wrote:
>
> On Mar 26, 2008, at 16:55 , Andy Koch wrote:
>> 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:0xb6d03444@./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?
>
> 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



Ryan Davis

3/28/2008 9:10:00 PM

0


On Mar 28, 2008, at 11:26 , Andy Koch 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.

AleXX

7/3/2008 2:40:00 PM

0

"AleXX" <nodeal@smalldeal.com> wrote in message
news:g4hf2i$kt$1@mawar.singnet.com.sg...
>
> "Observer" <observer111@yahoo1.com> wrote in message
> news:g4g72d$l4v$1@registered.motzarella.org...
>>
>> "truth" <truth@universe.com> wrote in message
>> news:M1Mak.16598$IK1.15521@news-server.bigpond.net.au...
>>> Singaporeans pls ask the pap mps and multi$million nincompoops
>>> how many $billions did the GIC and Temasek lost in the current
>>> down market.
>>
>>
>> You MORON!
>> These are NOT losses.
>> These are THIRTY YEAR "investment"
>> portfolios...
>> LOL.
>>
> He is moron and others calling you kah-chng-hole.
>
You are kah-kah-tooth !!??
Bwahaahahahahaha!!!!!!!!!!!!!!!!!!!