Created
October 24, 2014 15:38
-
-
Save janlimpens/478a3e9059032eae454b to your computer and use it in GitHub Desktop.
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
class Image | |
include Mongoid::Document | |
include Mongoid::Paperclip | |
include Mongoid::Slug | |
include ComparableByIndex | |
include CanBePublished | |
embedded_in :portfolio_item, inverse_of: :images | |
field :title, type: String | |
slug :title, history: true | |
field :description, type: String | |
field :technique | |
field :date, type: Date | |
has_mongoid_attached_file :image, | |
path: ':img_path.:extension', | |
url: ':img_url.:extension', | |
styles: {large: '780>', medium: '320>', small: '160x160#', mini: '80x80#'}, | |
use_timestamp: false | |
validates_attachment :image, content_type: { content_type: %w(image/jpg image/jpeg image/png image/gif)} | |
attr_accessor :delete_image | |
before_validation { image.clear if delete_image == '1' } | |
validates_presence_of :title | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment