典型情景:
SomeModule.find(:all, :conditions ["xyz" = ?, some_var]
SomeModule.find(:first, :conditions ["xyz" = ?, some_var]
SomeModule.find(:last, :conditions ["xyz" = ?, some_var]
Desired Equivilent:
虽然以上三个例子很棒,但我正在寻找正确的方法来询问“仅”特定列,例如:
SomeModule.find(:first_name, last_name, city :conditions ["xyz" = ?, some_var]
- 或许 - -
SomeModule.find(:only => :first_name, :last_name, :city :conditions ["xyz" = ?, some_var]
在查询中删除不必要的列的轨道方式是什么?
答案 0 :(得分:4)
SomeModule.find(:select => "first_name, last_name, city" ... )