Skip to content

Commit

Permalink
Adiciona condicionais para presença de published_at e edited_at
Browse files Browse the repository at this point in the history
  • Loading branch information
eliseuramos93 committed Feb 15, 2024
1 parent d216962 commit 34c09f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
8 changes: 5 additions & 3 deletions app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@
</p>
<% end %>
<p>
<time datetime="<%= @post.edited_at.to_date %>">
<%= t('.last_update', update_date: I18n.l(@post.edited_at.to_datetime, format: :long)) %>
</time>
<% if @post.edited_at.present? %>
<time datetime="<%= @post.edited_at.to_date %>">
<%= t('.last_update', update_date: I18n.l(@post.edited_at.to_datetime, format: :long)) %>
</time>
<% end %>
</p>

<p class="card-subtitle mb-2 text-body-secondary tags">
Expand Down
30 changes: 20 additions & 10 deletions app/views/reports/_post.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,26 @@

<p class="card-text"><%= post.content %></p>

<p class="card-subtitle mb-2">
<time datetime="<%= post.published_at.to_datetime %>">
<%= Post.human_attribute_name :published_at %> <%= I18n.l(post.published_at.to_datetime, format: :long) %>
</time>
</p>
<p>
<time datetime="<%= post.edited_at.to_date %>">
<%= t('posts.show.last_update', update_date: I18n.l(post.edited_at.to_datetime, format: :long)) %>
</time>
</p>
<% if post.published_at.present? %>
<p class="card-subtitle mb-2">
<time datetime="<%= post.published_at.to_datetime %>">
<%= Post.human_attribute_name :published_at %> <%= I18n.l(post.published_at.to_datetime, format: :long) %>
</time>
</p>
<% else %>
<p class="card-subtitle mb-2">
<time datetime="<%= post.created_at.to_datetime %>">
<%= Post.human_attribute_name :published_at %> <%= I18n.l(post.created_at.to_datetime, format: :long) %>
</time>
</p>
<% end %>
<% if post.edited_at.present? %>
<p>
<time datetime="<%= post.edited_at.to_date %>">
<%= t('posts.show.last_update', update_date: I18n.l(post.edited_at.to_datetime, format: :long)) %>
</time>
</p>
<% end %>

<p class="card-subtitle mb-2 text-body-secondary tags">
<% post.tags.each do |tag| %>
Expand Down

0 comments on commit 34c09f1

Please sign in to comment.