mardi 28 juillet 2015

Migration to add enum column in rails3 and enumerated_attribute

I need a migration to add column of type enum in rails 3. I will be using enumerated_attribute gem.

I generated a migration to add the column:

rails generate migration addUsage_reports_accessToClientParam usage_reports_access:enum

Now I need to set up the values for the enum and set the default value. Here is the generated migration:

class AddUsageReportsAccessToClientParam < ActiveRecord::Migration
  def self.up
    add_column :client_params, :usage_reports_access, :enum
  end

  def self.down
    remove_column :client_params, :usage_reports_access
  end
end

Thanks

Aucun commentaire:

Enregistrer un commentaire