Mysql ActiveRecord,选择查询数组返回ActiveRecord::StatementImportControllerIndex中无效

Mysql ActiveRecord,选择查询数组返回ActiveRecord::StatementImportControllerIndex中无效,mysql,ruby-on-rails,activerecord,smart-listing,Mysql,Ruby On Rails,Activerecord,Smart Listing,我有一个从backoffice创建的自定义列表,我在其中添加了要从DB表检索的列。这将成为一个数组。我只想从匹配Id的行中检索这些列 这是我的代码: def load_import_contacts @import_contacts_column_filter = current_user.current_organization.import_columns.split(/,/) # the "custom filter" that retrieve columns @impo

我有一个从backoffice创建的自定义列表,我在其中添加了要从DB表检索的列。这将成为一个数组。我只想从匹配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
错误消息:

头衔

正文信息

更多细节

Extracted source (around line #15): 
第15行:

@import_contacts_listing = smart_listing_create(
奇怪的解决方案:

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

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

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

请求对多个列进行一次计数是否有效?我想不是。我认为每个字段都应该有单独的计数…你的意思是什么?选择计数参考号、姓名、姓氏1、姓氏2、电话、地址、城市、邮编、地区、出生日期、首次访问、mutua、组织id。这是有效的sql语法吗?我想不是。我的意思是你要么选择所有字段的计数,计数*要么选择一个字段countid,但你不能选择countfield1,field2,…,除非我大错特错……我不能选择一个字段数组?
@import_contacts_listing = smart_listing_create(
**@import_contacts.each do |before|
end**