I had a users table and went back to add columns for first name and
last name. Just so it would not cause errors, I was trying to loop
through the existing users in the database and set the first name
column to "First" and the last name column to "Last"
Before updating to rails 2, i was able to do something like this:
class AddFirstNameAndLastNameToUsers < ActiveRecord::Migration
add_column :users, :first_name, :string
add_column :users, :last_name, :string
User.find(:all).each do |user|
user.first_name = 'First'
user.last_name = 'Last'
remove_column :users, :first_name
remove_column :users, :last_name
For some reason, the columns are created, but the names are never
changed. When looking at the database, everything is still NULL. When
calling save on the user object, I see MYSQL updates being made, but
without the columns that were just added.
I can't figure out why this won't work and would greatly appreciate