How can an ActiveRecord::Relation object call class methods

前端 未结 4 1387
礼貌的吻别
礼貌的吻别 2020-12-04 22:15

How can an ActiveRecord::Relation object call class methods?

class Project < ActiveRecord::Base
  has_many :tasks
end

class Task < ActiveRecord::Base
         


        
4条回答
  •  独厮守ぢ
    2020-12-04 22:45

    Here in ActiveRecord::Relation, Relation is representing whole table and your class Post is map with table,

    So ActiveRecord::Relation is array or single record it can access class method.

提交回复
热议问题