0

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.

1

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.