gpt4 book ai didi

mysql - ActiveRecord,选择查询数组返回 ActiveRecord::StatementInvalid in ImportsController#index

转载 作者:行者123 更新时间:2023-11-29 03:22:04 25 4
gpt4 key购买 nike

我有一个从“后台”创建的自定义列表,我在其中添加了我想从数据库表中检索的列。这成为一个数组。好吧,我只想从与 Id 匹配的行中检索那些列。

这是我的代码:

def load_import_contacts
@import_contacts_column_filter = current_user.current_organization.import_columns.split(/,/) # the "custom filter" that retrieve columns
@import_contacts = UserImport.select(@import_contacts_column_filter).where(organization_id: current_user.current_organization.id) # the query
# here all ok, objects filtered how i want.
@import_contacts_listing = smart_listing_create(
# here comes the error message
:import_contacts,
@import_contacts,
partial: 'contacts/listing_import',
default_sort: {created_at: "desc"}
)
end

错误信息:

标题

ActiveRecord::StatementInvalid in ImportsController#index 

正文

Mysql2::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ' name, surname1, surname2, phone, adress, city, zipcode, zone, birthdate, firstv' at line 1: SELECT COUNT(reference_number, name, surname1, surname2, phone, adress, city, zipcode, zone, birthdate, firstvisit, mutua, organization_id) FROM `user_imports` WHERE `user_imports`.`organization_id` = 279

更多详情

Extracted source (around line #15): 

第 15 行:

@import_contacts_listing = smart_listing_create(

最佳答案

奇怪的解决方案:

当我在智能列表之前添加这一行时

**@import_contacts.each do |before|
end**

一切正常,很奇怪,我不知道为什么会这样。

关于mysql - ActiveRecord,选择查询数组返回 ActiveRecord::StatementInvalid in ImportsController#index,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42607987/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com