Skip to content

Instantly share code, notes, and snippets.

@frankie-loves-jesus
Last active August 29, 2015 14:04
Show Gist options
  • Save frankie-loves-jesus/85567767c90a1b41cc72 to your computer and use it in GitHub Desktop.
Save frankie-loves-jesus/85567767c90a1b41cc72 to your computer and use it in GitHub Desktop.
class Photo < ActiveRecord::Base
belongs_to :post, :class_name => "Forem::Post"
has_attached_file :attachment,
path: ":rails_root/public/system/attachments/:id/:style/:filename",
url: "/system/attachments/:id/:style/:filename",
styles: {
display: "450x450>",
thumbnail: "70x70#"
},
convert_options: { all: "-quality 100" },
processors: [:thumbnail, :compression]
validates_attachment_presence :attachment
validates_attachment :attachment, content_type: {
content_type: ["image/jpg", "image/jpeg", "image/png", "image/gif"]
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment