Sha256: 1f8f2cb1c6ba4bfc324c6a66a6ccc5a1749e10ce1623899fd77196a10f53d45e
Contents?: true
Size: 914 Bytes
Versions: 3
Compression:
Stored size: 914 Bytes
Contents
module Polygallery class Photo < ActiveRecord::Base belongs_to :gallery, :class_name => 'Polygallery::Gallery' has_attached_file :photo, :styles => ->(p) { p.instance.paperclip_settings[:styles] }, :default_url => ->(p) { p.instance.paperclip_settings[:default_url] } validates_attachment_content_type :photo, :content_type => /\Aimage\/.*\Z/ # validates_attachment_presence :photo # TODO: make this a setting attr_accessor :photo_to_upload before_save :process_photo_to_upload def paperclip_settings if gallery.present? gallery.settings[:paperclip] else puts 'WARNING: Gallery not found! Using default paperclip settings...' Gallery::DEFAULTS[:paperclip] end end def process_photo_to_upload self.photo = File.open(photo_to_upload) if photo_to_upload.present? end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
polygallery-0.0.7 | app/models/polygallery/photo.rb |
polygallery-0.0.6 | app/models/polygallery/photo.rb |
polygallery-0.0.5 | app/models/polygallery/photo.rb |