app/models/spud_media.rb in spud_media-0.9.4 vs app/models/spud_media.rb in spud_media-0.9.5

- old
+ new

@@ -15,10 +15,11 @@ attr_accessible :attachment_content_type,:attachment_file_name,:attachment_file_size,:attachment, :is_protected, :crop_x, :crop_y, :crop_w, :crop_h, :crop_s validates_numericality_of :crop_x, :crop_y, :crop_w, :crop_h, :crop_s, :allow_nil => true before_create :rename_file + #after_create :validate_permissions before_update :validate_permissions def rename_file # remove periods and other unsafe characters from file name to make routing easier extension = File.extname(attachment_file_name) @@ -27,11 +28,11 @@ end def image_from_type if self.is_image? || self.is_pdf? - return self.attachment.url(:small) + return self.attachment_url(:small) elsif self.attachment_content_type.blank? return "spud/admin/files_thumbs/dat_thumb.png" elsif self.attachment_content_type.match(/jpeg|jpg/) @@ -139,17 +140,15 @@ end def validate_permissions_s3 if is_protected attachment.s3_object(:original).acl = :private - if attachment.s3_object(:cropped).exists? - attachment.s3_object(:cropped).acl = :private - end + attachment.s3_object(:cropped).acl = :private if attachment.s3_object(:cropped).exists? + attachment.s3_object(:small).acl = :private if attachment.s3_object(:small).exists? else attachment.s3_object(:original).acl = :public_read - if attachment.s3_object(:cropped).exists? - attachment.s3_object(:cropped).acl = :public_read - end + attachment.s3_object(:cropped).acl = :public_read if attachment.s3_object(:cropped).exists? + attachment.s3_object(:small).acl = :public_read if attachment.s3_object(:small).exists? end end end