为什么ARel查询作为ActiveRecord::Relation类而不是父类返回?

为什么ARel查询作为ActiveRecord::Relation类而不是父类返回?,activerecord,ruby-on-rails-3,arel,Activerecord,Ruby On Rails 3,Arel,我有一门课: class Technician < ActiveRecord::Base scope :named, lambda {|name| where(["first_name LIKE ?", "%#{name}%"])} end 这很重要,因为我在尝试访问类属性时遇到了无方法错误: technician.id => no method error 我做错了什么?Arel返回ActiveRecord::Relation,以便将执行推迟到最后一刻,并提

我有一门课:

class Technician < ActiveRecord::Base  
  scope :named, lambda {|name| where(["first_name LIKE ?", "%#{name}%"])}  
end  
这很重要,因为我在尝试访问类属性时遇到了无方法错误:

technician.id => no method error  
我做错了什么?

Arel返回ActiveRecord::Relation,以便将执行推迟到最后一刻,并提供更好的可组合性

Technician.namedjohn.first代替Technician.namedjohn获得技师

Arel返回ActiveRecord::Relation,以便将执行推迟到最后一刻,并提供更好的可组合性


Technician.namedjohn.first代替Technician.namedjohn获得技师

钱德拉…谢谢你的帮助。我自己要花很长时间才能弄清楚这些细微差别。钱德拉……谢谢你的帮助。我自己要花很长时间才能弄清楚这种细微差别。
technician.id => no method error