I have a default scope set in my model. However, when I call a particular model function from my rake task, I don't want the scope to be in effect. So, when my model is loaded, how can I tell if it was loaded within a rake task or not.
            Asked
            
        
        
            Active
            
        
            Viewed 160 times
        
    0
            
            
        - 
                    There is an answer may be helpful for you: http://stackoverflow.com/questions/1858230/how-to-detect-whether-my-rails-is-running-in-migration-or-not-in-environment-rb – Blue Smith Jul 29 '12 at 08:47
 
1 Answers
3
            The model should never know something like this. If you want your rake task to access your model without the default_scope kicking in, you should look at the with_exclusive_scope method.
See this blog post for an example.
        jdl
        
- 17,702
 - 4
 - 51
 - 54