From 42b5e37c9c560390efcc8d4965e747c4cfbbc6b0 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 2 Mar 2016 11:43:57 +0100 Subject: [PATCH] Improved file location detection. --- lib/notification_factory.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/notification_factory.rb b/lib/notification_factory.rb index 1b6376c57..25b0be97e 100644 --- a/lib/notification_factory.rb +++ b/lib/notification_factory.rb @@ -314,17 +314,18 @@ returns template_body = '' locale = data[:locale] || 'en' template = data[:template] - location = "app/views/mailer/#{template}/#{locale}.html.erb" + root = Rails.root + location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb" # as fallback, use 2 char locale if !File.exist?(location) locale = locale[0, 2] - location = "app/views/mailer/#{template}/#{locale}.html.erb" + location = "#{root}/app/views/mailer/#{template}/#{locale}.html.erb" end # as fallback, use en if !File.exist?(location) - location = "app/views/mailer/#{template}/en.html.erb" + location = "#{root}/app/views/mailer/#{template}/en.html.erb" end File.open(location, 'r:UTF-8').each do |line| @@ -340,7 +341,7 @@ returns if !data[:raw] application_template = nil - File.open('app/views/mailer/application.html.erb', 'r:UTF-8') do |file| + File.open("#{root}/app/views/mailer/application.html.erb", 'r:UTF-8') do |file| application_template = file.read end data[:objects][:message] = message_body