jlfenaux
jlfenaux

Reputation: 3291

Is there a way to know that a rails app has been launched from a rake command?

I'm doing a bunch of caching tasks in my rails initializers. They're useful for the website, but absolutely useless and time consuming when I launch rake tasks.

Is there a way in rails to know when the app has been launched from a rake command?

Thanks

Upvotes: 2

Views: 46

Answers (1)

Shadwell
Shadwell

Reputation: 34774

I guess the other option is to ask whether you can tell whether the app has been launched as a website and only run the initializers then.

In that case you should be able to set environment variables in whichever web server you are running the application and you may then be able to trigger your initializer when the environment variable is set. Something like:

if ENV['INITIALIZE_BLAH']
   # Do your website only initialization
end

Upvotes: 1

Related Questions