I had a quick question about setting the default value of a column in a Rails migration to a non-static value.
I have a "Users" table that already has the columns id, first_name, and last_name, and I want to add a new column called "username" that defaults to the user's last name. This is what I currently have:
class AddLoginToUsers < ActiveRecord::Migration
def change
add_column :users, :username, :string, :default => :last_name
end
end
Clearly, this does not produce the intended result (it defaults to the string "last_name"). How would I go about setting the default to the row's last_name value?
Thanks in advance.