Show related microposts on learning goals

This commit is contained in:
Trevor Vallender 2024-01-06 11:17:36 +00:00
parent 6b43cfa813
commit 658bc90ed7
3 changed files with 19 additions and 1 deletions

View File

@ -8,4 +8,10 @@ class LearningGoal < ApplicationRecord
has_and_belongs_to_many :tags has_and_belongs_to_many :tags
accepts_nested_attributes_for :tags accepts_nested_attributes_for :tags
def microposts
microposts = Micropost.none
tags.each { |tag| microposts = microposts.or(tag.microposts) }
microposts
end
end end

View File

@ -1,4 +1,5 @@
<div id="learning_goal_<%= @learning_goal.id %>" class="learning_goal"> <div id="learning_goal_<%= @learning_goal.id %>" class="learning_goal">
<%= link_to t(".edit"), edit_learning_goal_path(@learning_goal) if @learning_goal.user == current_user %>
<h2><%= @learning_goal.title %></h2> <h2><%= @learning_goal.title %></h2>
<p><%= @learning_goal.starts_on %>-<%= @learning_goal.ends_on %></p> <p><%= @learning_goal.starts_on %>-<%= @learning_goal.ends_on %></p>
<h3><%= t(".description") %></h3> <h3><%= t(".description") %></h3>
@ -7,5 +8,14 @@
<h3><%= t(".retrospective") %></h3> <h3><%= t(".retrospective") %></h3>
<p><%= @learning_goal.retrospective %></p> <p><%= @learning_goal.retrospective %></p>
<% end %> <% end %>
<%= link_to t(".edit"), edit_learning_goal_path(@learning_goal) if @learning_goal.user == current_user %>
<h3><%= t(".tags") %></h3>
<ul>
<% @learning_goal.tags.each do |tag| %>
<li><%= link_to tag.name, tag %></li>
<% end %>
</ul>
<h3><%= t(".related_microposts") %></h3>
<p><%= render @learning_goal.microposts %></p>
</div> </div>

View File

@ -18,3 +18,5 @@ en:
edit: Edit edit: Edit
description: Description description: Description
retrospective: Retrospective retrospective: Retrospective
tags: Tags
related_microposts: Related μposts