Module: Polygallery::HasPolygallery

Extended by:
ActiveSupport::Concern
Defined in:
lib/polygallery/has_polygallery.rb

Defined Under Namespace

Modules: ClassMethods, LocalInstanceMethods

Constant Summary collapse

DEFAULTS =
{
    :associations => {
        :gallery => {
            :class_name => '::Polygallery::Gallery',
            :as => :galleryable,
            :dependent => :destroy
        },
        :photos => {
            :class_name => '::Polygallery::Photo',
            # :before_add => :set_nest,
            :dependent => :destroy,
            :foreign_key => :gallery_id
        }
    },
    :association_names => {
        :gallery => :gallery,
        :photos => :photos
    },
    :nested_attributes => {
        :gallery => { :reject_if => :all_blank },
        :photos => {
          :allow_destroy => true,
          :reject_if => proc {|attributes|
            !attributes.key?('id') && attributes['photo'].nil? } }
    },
    :validates => {},
    :paperclip => {
      :styles => {:medium => '300x300#', :thumb => '100x100#'},
      :default_url => 'polygallery/thumbnail-missing.jpg'
    },
    :paperclip_validations => {
      :content_type => /\Aimage\/.*\Z/,
      :presence => false
    }
}