From 36fbf1a8f87d635eb95ad6797fc68058532d8625 Mon Sep 17 00:00:00 2001 From: benji Date: Wed, 17 Feb 2016 15:45:00 +0100 Subject: [PATCH] Format the balance of user --- app/helpers/application_helper.rb | 11 +++++++++++ app/views/users/show.html.haml | 4 +++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..c9cdb01 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,13 @@ module ApplicationHelper + def euro f + number_to_currency f, unit: '€' + end + + def euro_from_cents(f) + if f + euro (f / 100.0) + else + nil + end + end end diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 5ffcc59..5260746 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,4 +1,6 @@ -%h2= "#{@user.name} (balance: #{@user.balance/100.0})" +%h2 + = @user.name + %small= "balance: #{euro_from_cents @user.balance}" = render 'transactions/new'