我正在尝试将 act-as-taggable-on 的tagged_with
方法与这样的random()
订单一起使用,
Dvd.tagged_with(@site.tag, wild: true, any: true).order('RANDOM()').limit(20)
但我收到以下错误,
ActiveRecord::StatementInvalid: PG::Error: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
LINE 1: ... OR dvds_taggings_c684506.tag_id = 3786) ORDER BY RANDOM() L...
^
: SELECT DISTINCT dvds.* FROM "dvds" JOIN taggings dvds_taggings_c684506 ON dvds_taggings_c684506.taggable_id = "dvds".id AND dvds_taggings_c684506.taggable_type = 'Dvd' WHERE (dvds_taggings_c684506.tag_id = 72 OR dvds_taggings_c684506.tag_id = 2823 OR dvds_taggings_c684506.tag_id = 3786) ORDER BY RANDOM() LIMIT 20
知道如何解决这个问题吗?