Last active
August 29, 2015 14:11
-
-
Save yanmhlv/f6dc6bad5d635a0ef67c to your computer and use it in GitHub Desktop.
rails_admin + paperclip
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Gemfile | |
gem 'rails_admin' | |
gem 'paperclip' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# models/product.rb | |
class Product < ActiveRecord::Base | |
has_attached_file :logo, | |
styles: { | |
thumb: "100x100#", | |
small: "150x150>", | |
square: '200x200#', | |
medium: "200x200" }, | |
url: "/logos/:style/:hash.:extension", | |
hash_secret: "longSecretString", | |
default_url: "/logos/no-image-available.png" | |
# url: ":rails_root/public/photos/images/:id/:style/:basename.:extension" | |
validates_attachment :logo, :presence => true, | |
content_type: { content_type: "image/jpeg" }, | |
size: { in: 0..2.megabytes } | |
rails_admin do | |
label 'Товары' | |
field :logo, :paperclip | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment