Forum: Ruby on Rails generate a migration (from a plugin) to add a column with a default value to an existing table

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.
970ef3bb8a3dfdab9619a73bd47cff86?d=identicon&s=25 bide (Guest)
on 2009-01-27 12:03
(Received via mailing list)
I add a column to an existing table via the generator with the
following action:

  def cmi_local_assigns
    returning(assigns = {}) do
      assigns[:migration_action] = "add"
      assigns[:class_name] = "cmi_add_avatar_to_user#{class_name}"
      assigns[:table_name] = args[1]
      assigns[:attributes] = [Rails::Generator::GeneratedAttribute.new
("user_avatar", "string")]
    end
  end

This works fine, bug now I want to add a default value for the newly
created column.
How is this possible?
The Rails::Generator::GeneratedAttribute.new allows just two
parameters.

Any ideas?
Thanks,
Bernd
This topic is locked and can not be replied to.