开发者

How to know if model is used from Rake?

开发者 https://www.devze.com 2022-12-30 01:34 出处:网络
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

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
0

精彩评论

暂无评论...
验证码 换一张
取 消