From 811c329199917a5e41c596baff5fdaabd9d2510b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juanjo=20Baz=C3=A1n?= Date: Wed, 9 Sep 2015 14:57:27 +0200 Subject: [PATCH] changes how comment.created_at is shown time_ago_in_words is not cache friendly --- app/views/comments/_comment.html.erb | 2 +- config/locales/rails.en.yml | 3 +++ config/locales/rails.es.yml | 1 + spec/features/comments_spec.rb | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index d8856f315..3b0ad67e0 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -59,7 +59,7 @@ <% end %> -  • <%= time_ago_in_words(comment.created_at) %> +  • <%= l comment.created_at.to_datetime, format: :datetime %> <% if comment.as_administrator? %> diff --git a/config/locales/rails.en.yml b/config/locales/rails.en.yml index cb5bdc38f..e45dfce7e 100644 --- a/config/locales/rails.en.yml +++ b/config/locales/rails.en.yml @@ -20,3 +20,6 @@ # available at http://guides.rubyonrails.org/i18n.html. en: + time: + formats: + datetime: "%Y-%m-%d %H:%M:%S" diff --git a/config/locales/rails.es.yml b/config/locales/rails.es.yml index 9a6e698d2..31cc02e92 100644 --- a/config/locales/rails.es.yml +++ b/config/locales/rails.es.yml @@ -196,4 +196,5 @@ es: default: "%A, %d de %B de %Y %H:%M:%S %z" long: "%d de %B de %Y %H:%M" short: "%d de %b %H:%M" + datetime: "%d/%m/%Y %H:%M:%S" pm: pm \ No newline at end of file diff --git a/spec/features/comments_spec.rb b/spec/features/comments_spec.rb index 2bdd380bd..40e75a281 100644 --- a/spec/features/comments_spec.rb +++ b/spec/features/comments_spec.rb @@ -14,7 +14,7 @@ feature 'Comments' do comment = Comment.last within first('.comment') do expect(page).to have_content comment.user.name - expect(page).to have_content time_ago_in_words(comment.created_at) + expect(page).to have_content I18n.l(comment.created_at, format: :datetime) expect(page).to have_content comment.body end end