I'm adding some columns to one of my database tables, and then populating those columns:
def self.up
add_column :contacts, :business_id, :integer
add_column :contacts, :business_type, :string
Contact.reset_column_information
Contact.all.each do |contact|
contact.update_attributes(:business_id => contact.client_id, :business_type => 'Client')
end
remove_column :contacts, :client_id
end
The line contact.update_attributes is causing the following Authlogic error:
You must activate the Authlogic::Session::Base.controller with a controller object before creating objects
I have no idea what is going on here - I'm not using a controller method to modify each row in the table. Nor am I creating new objects.
The error doesn't occur if the contacts table is empty.
I've had a google and it seems like this error can occur when you run your controller tests, and is fixed by adding before_filter :activate_authlogic to them, but this doesn't seem relevant in my case.
Any ideas? I'm stumped.