2024-01-06 09:42:36 +00:00
|
|
|
class LearningGoal < ApplicationRecord
|
|
|
|
belongs_to :user
|
2024-01-07 13:50:53 +00:00
|
|
|
has_many :todos
|
|
|
|
has_and_belongs_to_many :tags
|
|
|
|
accepts_nested_attributes_for :tags
|
2024-01-06 09:42:36 +00:00
|
|
|
|
2024-01-06 10:29:41 +00:00
|
|
|
has_rich_text :description
|
|
|
|
has_rich_text :retrospective
|
2024-01-07 13:22:21 +00:00
|
|
|
validates :completed, inclusion: { in: [true, false] }
|
2024-01-06 09:42:36 +00:00
|
|
|
|
|
|
|
validates :title, presence: true
|
2024-01-06 11:10:56 +00:00
|
|
|
|
2024-01-06 11:17:36 +00:00
|
|
|
def microposts
|
|
|
|
microposts = Micropost.none
|
|
|
|
tags.each { |tag| microposts = microposts.or(tag.microposts) }
|
2024-01-07 13:50:53 +00:00
|
|
|
microposts.uniq
|
2024-01-06 11:17:36 +00:00
|
|
|
end
|
2024-01-06 09:42:36 +00:00
|
|
|
end
|