Sha256: 8f1c792107858936daf18441406a10123a71191783d5bd3e5a3efe784fe3d115

Contents?: true

Size: 626 Bytes

Versions: 30

Compression:

Stored size: 626 Bytes

Contents

class Picture < ActiveRecord::Base

  belongs_to :product

  mount_uploader :picture, PictureUploader

  validates_presence_of :picture

  before_save :update_picture_attributes

  %w(tiny tiny_plus small small_plus medium medium_plus large large_plus).each do |version|
    define_method :"#{version}_height" do
      picture.send(version).height
    end

    define_method :"#{version}_width" do
      picture.send(version).width
    end
  end

  private

  def update_picture_attributes
    if picture.present?
      self.content_type = picture.file.content_type
      self.file_size = picture.file.size
    end
  end

end

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
nimbleshop_core-0.0.23 app/models/picture.rb
nimbleshop_core-0.0.21 app/models/picture.rb
nimbleshop_core-0.0.20 app/models/picture.rb
nimbleshop_core-0.0.19 app/models/picture.rb
nimbleshop_core-0.0.17 app/models/picture.rb
nimbleshop_core-0.0.16 app/models/picture.rb
nimbleshop_core-0.0.15 app/models/picture.rb
nimbleshop_core-0.0.14 app/models/picture.rb
nimbleshop_core-0.0.14.rc2 app/models/picture.rb
nimbleshop_core-0.0.14.rc1 app/models/picture.rb
nimbleshop_core-0.0.13 app/models/picture.rb
nimbleshop_core-0.0.12 app/models/picture.rb
nimbleshop_core-0.0.11 app/models/picture.rb
nimbleshop_core-0.0.10 app/models/picture.rb
nimbleshop_core-0.0.9 app/models/picture.rb
nimbleshop_core-0.0.8 app/models/picture.rb
nimbleshop_core-0.0.7 app/models/picture.rb
nimbleshop_core-0.0.5 app/models/picture.rb
nimbleshop_core-0.0.4.beta1 app/models/picture.rb
nimbleshop_core-0.0.4 app/models/picture.rb