Enum error in Rails 7.1.2 with Postgres Undefined column

175 views Asked by At

An error occurred when inspecting the object:

#<ActiveRecord::StatementInvalid:"PG::UndefinedColumn: ERROR:  column product_proposals.status_ids does not exist\nLINE 1: ...oduct_proposals\".* FROM \"product_proposals\" WHERE \"product_p...\n                                                             ^\nHINT:  Perhaps you meant to reference the column \"product_proposals.status_id\".\n">'

This the method i am using:

attribute :status_ids, :string
  attribute :type_ids, :string
 
  enum :status_ids, [
    pending: 0,
    verified: 1,
    work_in_progress: 2,
    complete: 3
]

  enum :type_ids, {
    price_variance: 0,
    oos_in_store: 1,
    not_in_store_file: 2,
    not_in_master_db: 3,
    data_not_correct: 4
  }

I have explicitly defined the attributes because this error was showing up:

Undeclared attribute type for enum 'type_ids'. Enums must be backed by a database column or declared with an explicit type via `attribute`. (RuntimeError)

I want a permanent fix for this

0

There are 0 answers