Guest User

Untitled

a guest
May 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. class Note < ActiveRecord::Base
  2. def file= file
  3. if file.present?
  4. # do something with the file
  5. if /image/.match(file.content_type)
  6. type = "Image"
  7. elsif /video/.match(file.content_type)
  8. type = "Video"
  9. else
  10. type = "Other"
  11. end
  12.  
  13. self.save
  14. asset = self.assets.create do |a|
  15. a.type = type
  16. a.file = file
  17. end
  18.  
  19. if type == "Video"
  20. asset.encode
  21. end
  22. end
  23. end
  24. end
Add Comment
Please, Sign In to add comment