aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobin Houston <robin.houston@gmail.com>2012-01-29 16:19:19 +0000
committerRobin Houston <robin.houston@gmail.com>2012-01-29 16:19:19 +0000
commitc61827cb60831b83e9516d2ac79ff514b5e1bf42 (patch)
tree85caf497ac83faf35d4e394646214668a3b8ad8c
parentd93498ac60529984177f00c37a5f905d45ee94ad (diff)
Raise exception if $RAILS_ENV is unset
If $RAILS_ENV is unset, raise an exception rather than just blithely creating a directory called cache/attachments_.
-rw-r--r--app/models/foi_attachment.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb
index 74346227b..da92d1c2d 100644
--- a/app/models/foi_attachment.rb
+++ b/app/models/foi_attachment.rb
@@ -38,7 +38,11 @@ class FoiAttachment < ActiveRecord::Base
BODY_MAX_DELAY = 5
def directory
- base_dir = File.join(File.dirname(__FILE__), "../../cache", "attachments_#{ENV['RAILS_ENV']}")
+ rails_env = ENV['RAILS_ENV']
+ if rails_env.nil? || rails_env.empty?
+ raise "$RAILS_ENV is not set"
+ end
+ base_dir = File.join(File.dirname(__FILE__), "../../cache", "attachments_#{rails_env}")
return File.join(base_dir, self.hexdigest[0..2])
end