Forum: Ruby on Rails save doesn't work in migration

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Eric L. (Guest)
on 2009-05-07 09:19
(Received via mailing list)
I'm writing a migration to merge my first and last name fields into a
single name field.  However, writing to the new name column doesn't
work within the migration.  Why is this so?

def self.up
  add_column :users, :name, :string

  for user in User.all
    user.name = user.first_name + ' ' + user.last_name
    user.save! # <= name is not actually saved here.
  end

  remove_column :users, :first_name
  remove_column :users, :last_name
end
Eric L. (Guest)
on 2009-05-07 09:40
(Received via mailing list)
Never mind, after some Googling, found reset_column_info to be my
answer.
This topic is locked and can not be replied to.