Skip to content

Instantly share code, notes, and snippets.

@yanmhlv
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yanmhlv/f6dc6bad5d635a0ef67c to your computer and use it in GitHub Desktop.
Save yanmhlv/f6dc6bad5d635a0ef67c to your computer and use it in GitHub Desktop.
rails_admin + paperclip
# Gemfile
gem 'rails_admin'
gem 'paperclip'
# 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