Using ActiveRecord::Base.transaction in a rake task?
Posted
by Brian Jordan
on Stack Overflow
See other posts from Stack Overflow
or by Brian Jordan
Published on 2010-05-27T16:07:52Z
Indexed on
2010/05/27
17:51 UTC
Read the original article
Hit count: 237
I am writing a rake task which, at one point, uses a custom YAML file import method to seed the database.
At one point in the import code, I have:
ActiveRecord::Base.transaction do
Trying to run the rake task throws:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]
The stack trace points to the aforementioned line in the code.
Is there a way to instantiate ActiveRecord::Base during a rake task?
Thanks!
© Stack Overflow or respective owner