diff options
author | Robin Houston <robin.houston@gmail.com> | 2012-06-20 13:58:05 +0100 |
---|---|---|
committer | Robin Houston <robin.houston@gmail.com> | 2012-06-20 13:58:05 +0100 |
commit | a7cc84b9b2b430644fe23e6328d7ab289e7abf0a (patch) | |
tree | f327332c83d35741405be98641fa5b474db2179f /app/models/raw_email.rb | |
parent | 6ef57090e436e01bc5de801bc7acb6bfadb5c490 (diff) | |
parent | 89459d3902583fa3d6dad78462d2bf2fa6f94db6 (diff) |
Merge branch 'feature/public-body-api' into develop
Diffstat (limited to 'app/models/raw_email.rb')
-rw-r--r-- | app/models/raw_email.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/app/models/raw_email.rb b/app/models/raw_email.rb index 1466e5d9c..3bb794684 100644 --- a/app/models/raw_email.rb +++ b/app/models/raw_email.rb @@ -19,13 +19,12 @@ class RawEmail < ActiveRecord::Base has_one :incoming_message - # We keep the old data_text field (which is of type text) for backwards - # compatibility. We use the new data_binary field because only it works - # properly in recent versions of PostgreSQL (get seg faults escaping - # some binary strings). - def directory request_id = self.incoming_message.info_request.id.to_s + if request_id.empty? + raise "Failed to find the id number of the associated request: has it been saved?" + end + if ENV["RAILS_ENV"] == "test" return File.join(Rails.root, 'files/raw_email_test') else @@ -36,7 +35,11 @@ class RawEmail < ActiveRecord::Base end def filepath - File.join(self.directory, self.incoming_message.id.to_s) + incoming_message_id = self.incoming_message.id.to_s + if incoming_message_id.empty? + raise "Failed to find the id number of the associated incoming message: has it been saved?" + end + File.join(self.directory, incoming_message_id) end def data=(d) |