seminar/custom_gallery/app/models/custom_album_image.rb

27 lines
829 B
Ruby
Raw Normal View History

require 'net/http'
class CustomAlbumImage
include Mongoid::Document
include Mongoid::Timestamps
include OrbitTag::Taggable
mount_uploader :file, CustomGalleryUploader
field :title
field :title_translations, type: Hash, default: {}
field :description, localize: true
field :rss2_id, type: String
field :order, type: Integer, default: -1
# has_and_belongs_to_many :tags, :class_name => "CustomGalleryTag"
def title_translations
tmp = super || {}
if tmp == {}
tmp = I18n.available_locales.collect{|locale| [locale,self[:title]]}.to_h
end
tmp
end
def title
self.title_translations[I18n.locale]
end
belongs_to :custom_album
has_many :custom_album_crops, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :custom_album_crops, :allow_destroy => true
end