diff --git a/app/models/learning_goal.rb b/app/models/learning_goal.rb index f818af9..0881b08 100644 --- a/app/models/learning_goal.rb +++ b/app/models/learning_goal.rb @@ -8,4 +8,10 @@ class LearningGoal < ApplicationRecord has_and_belongs_to_many :tags accepts_nested_attributes_for :tags + + def microposts + microposts = Micropost.none + tags.each { |tag| microposts = microposts.or(tag.microposts) } + microposts + end end diff --git a/app/views/learning_goals/show.html.erb b/app/views/learning_goals/show.html.erb index 798d5cf..71507e5 100644 --- a/app/views/learning_goals/show.html.erb +++ b/app/views/learning_goals/show.html.erb @@ -1,4 +1,5 @@
<%= @learning_goal.starts_on %>-<%= @learning_goal.ends_on %>
<%= @learning_goal.retrospective %>
<% end %> - <%= link_to t(".edit"), edit_learning_goal_path(@learning_goal) if @learning_goal.user == current_user %> + +<%= render @learning_goal.microposts %>