ActiveRecord .select(): Possible to clear old selects?

后端 未结 2 1365
不知归路
不知归路 2020-12-14 15:59

Is there a way to clear old selects in a .select(\"table.col1, ...\") statement?

Background:

I have a scope that requests accessible items for a given user i

2条回答
  •  再見小時候
    2020-12-14 16:23

    Fortunately you're wrong :D, you can use the #except method to remove some parts of the query made by the relation, so if you want to remove the SELECT part just do :

    @items = Item.accessible(@auth.id).except(:select).select("polls.id, polls.title")
    

提交回复
热议问题