From ed8953f05638c43d9c1e62cf3d3ff7da158f4c20 Mon Sep 17 00:00:00 2001 From: Stefan Wintermeyer Date: Sun, 30 Dec 2012 19:47:15 +0100 Subject: Added a First Steps page. --- app/helpers/application_helper.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'app/helpers/application_helper.rb') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index de6be79..de4d677 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,2 +1,22 @@ module ApplicationHelper + + # nicely_joined_with_commata(['1', '2', '3', '4']) + # = '1, 2, 3 und 4' + # + def nicely_joined_with_commata(array_of_things) + if array_of_things.count == 1 + array_of_things.first.to_s + else + if array_of_things.count > 1 + output = array_of_things[0, array_of_things.count - 1].map{|item| item.to_s}.join(', ') + if I18n.locale == :de + output += ' und ' + else + output += ' and ' + end + output += array_of_things.last.to_s + end + end + end + end -- cgit v1.2.3