【发布时间】:2010-11-20 17:59:06
【问题描述】:
我有一堂课:
class Technician < ActiveRecord::Base
scope :named, lambda {|name| where(["first_name LIKE ?", "%#{name}%"])}
end
在 Rails 控制台中,当我执行以下查询时:
technician = Technician.named("john")
technician.class => ActiveRecord::Relation and not Technician
这很重要,因为当我尝试访问类属性时出现无方法错误:
technician.id => no method error
我做错了什么?
【问题讨论】:
标签: activerecord ruby-on-rails-3 arel