Sha256: 6b4188b0d8c06586105b8d3eb64d1a43aaa7e258e6a3b278eb274e1867121b45

Contents?: true

Size: 712 Bytes

Versions: 12

Compression:

Stored size: 712 Bytes

Contents

# coding: utf-8

module Redditor
  class Image < ActiveRecord::Base
    self.table_name = "redditor_images"

    after_initialize :default_values # чтобы файл загружался, пока через html5 не передаем позицию

    # attr_accessible :descr, :imageable_id, :imageable_type, :position, :src, :temp_id
    attr_accessor :temp_id

    mount_uploader :src, RedditorUploader

    validates :src, :presence => true

    belongs_to :imageable, :polymorphic => true

    default_scope -> { order(:position) }

    def self.model_name
      ActiveModel::Name.new(self, nil, 'Image')
    end

    private
      def default_values
        self.position ||= 1000
      end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
redditor-0.1.11 app/models/redditor/image.rb
redditor-0.1.10 app/models/redditor/image.rb
redditor-0.1.9 app/models/redditor/image.rb
redditor-0.1.8 app/models/redditor/image.rb
redditor-0.1.7 app/models/redditor/image.rb
redditor-0.1.6 app/models/redditor/image.rb
redditor-0.1.5 app/models/redditor/image.rb
redditor-0.1.4 app/models/redditor/image.rb
redditor-0.1.3 app/models/redditor/image.rb
redditor-0.1.2 app/models/redditor/image.rb
redditor-0.1.1 app/models/redditor/image.rb
redditor-0.1.0 app/models/redditor/image.rb