mardi 28 mars 2017

ActiveRecord::Enum - PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer:

I am having a strange error and was hoping someone could point me in the right direction. I have a model called Organizations, and a attribute called department, see the excerpt from the schema below:

t.integer  "department",  default: 0

Inside my model have defined my enums for this attribute, as I am using ActiveRecord::Enum, like below:

enum department: [:conferences, :design_teams, :services, :clubs, :events, :communications]

But when I query, JobPosting.joins(job: :organization).where(organizations: { department: 'conferences' }) I get an error that reads:

PG::InvalidTextRepresentation: ERROR: invalid input syntax for integer: "conferences"

FYI: An Organization has_many Jobs, and Job has_many JobPostings.

But when I query Organization.where(department: 'conferences') it works.

Any help would be greatly appreciated.

Aucun commentaire:

Enregistrer un commentaire