How to know if model is used from Rake?
In a model, I include a module used by a Rake task.
I would like to do this include only for rake and not for Rails.开发者_如何学Go
I didn't find any method to know if the model is used by Rails or Rake.
I use Rails3.0.beta3.
If you have any idea i would be glad to hear them :)
Thanks
You can solve your problem with defined variable.
You define a variable into your rake task
RAKE_TASK = true
And in your model you test it with defined?
if defined? RAKE_TASK
def your_method
end
精彩评论