Home > Software design >  undefined method for #<ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition
undefined method for #<ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition

Time:08-12

I can add a column with custom data type using the following code

def change
  add_column :assessorials, :metric_type, :assessorial_metric_type
end

The above code adds a new metric_type column of type assessorial_metric_type to the assessorials table

Now i have to create a new table which contains a column metric_type of type assessorial_metric_type

I have tried the following code.

create_table :charges do |t|
  t.string :title
  t.assessorial_metric_type :metric_type
end

This gives the error undefined method `assessorial_metric_type' for #<ActiveRecord::ConnectionAdapters::PostgreSQL::TableDefinition:

Any idea on how to fix this?

CodePudding user response:

  t.column :metric_type, :assessorial_metric_type
  • Related