问题描述
我有一个奇怪的错误,希望有人能指出我正确的方向。我有一个名为Organizations的模型,以及一个名为 department
的属性,请参见下面的架构摘录:
t.integerdepartment,默认值:0
已定义了此属性的枚举,因为我使用的是 ,如下所示:
枚举部门:[:会议,设计团队,服务,俱乐部,事件,通信]
但是当我查询 JobPosting.joins(job::organization)其中(组织:{department:'meetings'})
我得到一个错误,内容如下:
PG :: InvalidTextRepresentation:错误:整数的无效输入语法:会议
FYI:组织has_many作业和作业has_many JobPostings。 >
但是当我查询 Organization.where(出发点
任何帮助将不胜感激。
这适用于ror5。
JobPosting.joins(job::organization ).where(organization:
{department:Organization.departments ['meetings']})
我甚至不确定如果枚举
是在ror3。
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.
This works on ror5.
JobPosting.joins(job: :organization).where(organizations:
{ department: Organization.departments['conferences'] })
I'm not even sure if enum
was available in ror3.
这篇关于ActiveRecord :: Enum - PG :: InvalidTextRepresentation:ERROR:整数的无效输入语法:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!