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开发者_StackOverflow中文版 to know when the app has been launched from a rake command?
Thanks
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
精彩评论