我收到任务:完成的活动记录
添加一个方法叫做得到完成计数的用户模型类,其中:
•接受用户作为参数
•确定TodoItems数量用户使用聚合查询功能
完成- (提示:你正在寻找与特定用户相关TodoItems的计数,其中完成:真)
•返回
class User < ActiveRecord::Base
has_one :profile, dependent: :destroy
has_many :todo_lists, dependent: :destroy
has_many :todo_items, through: :todo_lists, source: :todo_items, dependent: :destroy
validates :username, presence: true
def get_completed_count
todo_items.length
end
end
有谁可以解释一下什么是完整的方法不计?
谢谢,迈克尔。
你有什么问题吗? – matanco
如何完成任务.... –