Advertisement
Guest User

Untitled

a guest
Dec 17th, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.58 KB | None | 0 0
  1. <%= simple_form_for(@post, html: {class: 'form-horizontal' }) do |f| %>
  2. <%= f.error_notification %>
  3. <%= f.input_field :title, placeholder: "Enter Title" %>
  4. <%= f.input_field :body, id: "body-field", placeholder: "Provide all the facts." %>
  5. <%= f.input_field :photo %>
  6. <%= f.input_field :file %>
  7. <%= f.button :submit, class: "btn btn-primary pull-left" %>
  8. <% end %>
  9.  
  10. class PhotoUploader < CarrierWave::Uploader::Base
  11. include CarrierWave::RMagick
  12. storage :fog
  13.  
  14. include CarrierWave::MimeTypes
  15. process :set_content_type
  16.  
  17. def store_dir
  18. "images/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  19. end
  20.  
  21. version :main_thumb_mobile do
  22. process :resize_to_fit => [52, 52]
  23. end
  24.  
  25. version :main_thumb do
  26. process :resize_to_fit => [150, 150]
  27. end
  28.  
  29. version :post_thumb do
  30. process :resize_to_fit => [200, 200]
  31. end
  32.  
  33. version :large do
  34. process :resize_to_limit => [400, 400]
  35. end
  36.  
  37. def extension_white_list
  38. %w(jpg jpeg gif png)
  39. end
  40. end
  41.  
  42. class FileUploader < CarrierWave::Uploader::Base
  43. storage :fog
  44. def store_dir
  45. "files/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
  46. end
  47.  
  48. def extension_white_list
  49. %w(pdf doc docx xls xlsx ppt pptx txt mp4 m4v mov avi mkv mp3 wav)
  50. end
  51. end
  52.  
  53. # == Schema Information
  54. # truncated for brevity
  55. # Table name: posts
  56. #
  57. # id :integer not null, primary key
  58. # title :text
  59. # photo :string(255)
  60. # body :text
  61. # user_id :integer
  62. # file :string(255)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement