Guest User

Untitled

a guest
May 25th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. class Upload < ActiveRecord::Base
  2. has_attachment :content_type => ['application/pdf', :image],
  3. :processor => :MiniMagick,
  4. :storage => :file_system,
  5. :path_prefix => 'uploads',
  6. ##:max_size => 500.kilobytes,
  7. ##:resize_to => '384x256>',
  8. :thumbnails => {
  9. :large => '96x96>',
  10. :medium => '64x64>',
  11. :small => '48x48>'
  12. }
  13.  
  14. validates_as_attachment
  15.  
  16.  
  17. ## there are no public filenames for these files
  18. def public_filename
  19. false
  20. end
  21.  
  22. def full_filename(thumbnail = nil)
  23. file_system_path = (thumbnail ? thumbnail_class : self).attachment_options[:path_prefix].to_s
  24. File.join(RAILS_ROOT, file_system_path, *partitioned_path(thumbnail_name_for(thumbnail)))
  25. end
  26.  
  27. end
Add Comment
Please, Sign In to add comment