diff options
author | Seb Bacon <seb.bacon@gmail.com> | 2012-01-08 09:38:43 +0000 |
---|---|---|
committer | Seb Bacon <seb.bacon@gmail.com> | 2012-01-08 09:38:59 +0000 |
commit | a5f6dc2d8af9a12c05c1b6e3897292f2eaee3ab0 (patch) | |
tree | cad5980fa17bcaf43502373e929d63b584b1d20e /app/models | |
parent | ee33ae705f3af6989931982c8d2ac57344a07e28 (diff) |
Don't give error when viewing HTML versions. Fixes issue #321
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/foi_attachment.rb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index 057dcdb69..16e202bee 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -19,7 +19,7 @@ class FoiAttachment < ActiveRecord::Base before_destroy :delete_cached_file! def directory - base_dir = File.join("cache", "attachments_#{ENV['RAILS_ENV']}") + base_dir = File.join(File.dirname(__FILE__), "../../cache", "attachments_#{ENV['RAILS_ENV']}") return File.join(base_dir, self.hexdigest[0..2]) end @@ -302,7 +302,7 @@ class FoiAttachment < ActiveRecord::Base body = $1.to_s body_without_tags = body.gsub(/\s+/,"").gsub(/\<[^\>]*\>/, "") contains_images = html.match(/<img/mi) ? true : false - if !$?.success? || html.size == 0 || (body_without_tags.size == 0 && !contains_images) + if html.size == 0 || !$?.success? || (body_without_tags.size == 0 && !contains_images) ret = "<html><head></head><body>"; if self.has_google_docs_viewer? wrapper_id = "wrapper_google_embed" |