Activerecord activeadmin和acts作为标记生成不明确的列名错误

Activerecord activeadmin和acts作为标记生成不明确的列名错误,activerecord,activeadmin,formtastic,acts-as-taggable-on,acts-as-taggable,Activerecord,Activeadmin,Formtastic,Acts As Taggable On,Acts As Taggable,我正在使用active_admin并将其作为标记,我正在尝试制作一个过滤器。以下是型号代码: class Person < ApplicationRecord acts_as_taggable_on :expertise, :industry end 以下是我在提交筛选器时遇到的错误: filter :industry, as: :select, collection: Person.industry_counts.pluck(:name, :name) SQLite3::SQ

我正在使用active_admin并将其作为标记,我正在尝试制作一个过滤器。以下是型号代码:

class Person < ApplicationRecord
    acts_as_taggable_on :expertise, :industry
end
以下是我在提交筛选器时遇到的错误:

filter :industry, as: :select, collection: Person.industry_counts.pluck(:name, :name)
SQLite3::SQLException: ambiguous column name: created_at: SELECT COUNT(DISTINCT "people"."id") FROM "people" LEFT OUTER JOIN "taggings" ON "taggings"."taggable_id" = "people"."id" AND "taggings"."context" = ? AND "taggings"."taggable_type" = ? WHERE "taggings"."tag_id" = 0 AND (created_at > '2017-01-17 00:22:53.923894')

如何修复此问题?

事实证明,active\u admin使用ransack gem来处理其过滤器。我必须在模型中制作定制的“洗劫者”来实现这一点:

def self.in_industry(industries)
  Person.tagged_with(industries, :any => true, :on => :industry).select{|a| a} #use select to convert relation to array
end

ransacker :by_industry, formatter: proc{ |v|
  data = Person.in_industry(v).map(&:id)
  data = data.present? ? data : nil
} do |parent|
  parent.table[:id]
end
我从以下文章和评论中的更正中得到了这一点:


问题在于
在2017-01-17 00:22:53.923894创建的
标记和
上都存在
上创建的
你能把代码张贴在调用该代码的地方吗?好像少了什么东西