Add "updated at" to blog posts

This commit is contained in:
Trevor Vallender 2023-10-16 08:06:26 +01:00
parent 01bcdf3a2d
commit 1451104b75
3 changed files with 7 additions and 1 deletions

View File

@ -14,4 +14,10 @@ module ApplicationHelper
render "shared/flash" render "shared/flash"
end end
end end
def updated_at(object)
return "" if object.created_at == object.updated_at
object.updated_at.strftime("%Y-%m-%d %H:%M")
end
end end

View File

@ -3,6 +3,7 @@
<p><%= @blog_post.content %></p> <p><%= @blog_post.content %></p>
<div class="created_at"> <div class="created_at">
<%= link_to "Edit", edit_blog_post_path(@blog_post) if @blog_post.user == current_user %> <%= link_to "Edit", edit_blog_post_path(@blog_post) if @blog_post.user == current_user %>
<%= "Updated at #{updated_at(@blog_post)} | " %>
<%= link_to @blog_post.created_at.strftime("%Y-%m-%d %H:%M"), @blog_post %> <%= link_to @blog_post.created_at.strftime("%Y-%m-%d %H:%M"), @blog_post %>
</div> </div>
</div> </div>

View File

@ -45,7 +45,6 @@ Rails.application.configure do
# config.action_cable.url = "wss://example.com/cable" # config.action_cable.url = "wss://example.com/cable"
# config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ] # config.action_cable.allowed_request_origins = [ "http://example.com", /http:\/\/example.*/ ]
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = false config.force_ssl = false
config.assume_ssl = true config.assume_ssl = true