遵循Rails测试处方。 Task
表具有名为completed_at
的列。为什么我只能用self.completed_at = date
来写(completed_at = date
失败),但是我可以在self
方法中不用complete?
来访问属性?
class Task < ApplicationRecord
belongs_to :project
def mark_completed(date = Time.current)
self.completed_at = date
end
def complete?
completed_at.present?
end
end
预先感谢