这个错误提示的意思是查询条件中的 'region' 列有二义性,即不清楚是哪个表的列。可能是因为在 SQL 查询语句中使用到了多个表,并且这些表中都包含了 'region' 这个列。

为了解决这个问题,需要在查询条件中指定表名或者使用别名。例如,如果查询中涉及了 users 表和 region 表,并且这两个表中都有 'region' 列,那么可以这样修改查询语句:

SELECT users.* FROM users INNER JOIN region ON users.region_id=region.id WHERE region.region='xxx';

上述查询语句使用了 INNER JOIN 来链接 users 表和 region 表,同时将 users 表中的 region_id 列和 region 表中的 id 列进行关联。然后在查询条件 WHERE 中使用表名或者别名来指定 'region' 列属于哪个表,例如这里指定为 region.region。

根据具体情况进行修改即可。

@enterprise_personnels = @enterprise_personnels.joins(:region).where('regions.region = ?', params[:region]) if params[:region].present?