Sha256: 01794a6fca3ea8bdd0761267ae7454c09ee5260eeee5182b09ed214c41b509a4

Contents?: true

Size: 893 Bytes

Versions: 15

Compression:

Stored size: 893 Bytes

Contents

module Spree
  class Image < Asset
    include Configuration::ActiveStorage
    include Rails.application.routes.url_helpers
  
    # In Rails 5.x class constants are being undefined/redefined during the code reloading process
    # in a rails development environment, after which the actual ruby objects stored in those class constants
    # are no longer equal (subclass == self) what causes error ActiveRecord::SubclassNotFound
    # Invalid single-table inheritance type: Spree::Image is not a subclass of Spree::Image.
    # The line below prevents the error.
    self.inheritance_column = nil

    def styles
      self.class.styles.map do |_, size|
        width, height = size[/(\d+)x(\d+)/].split('x')

        {
          url: polymorphic_path(attachment.variant(resize: size), only_path: true),
          width: width,
          height: height
        }
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_core-4.0.9 app/models/spree/image.rb
spree_core-4.0.8 app/models/spree/image.rb
spree_core-4.0.7.1 app/models/spree/image.rb
spree_core-4.0.7 app/models/spree/image.rb
spree_core-4.0.6 app/models/spree/image.rb
spree_core-4.0.5 app/models/spree/image.rb
spree_core-4.0.4 app/models/spree/image.rb
spree_core-4.0.3 app/models/spree/image.rb
spree_core-4.0.2 app/models/spree/image.rb
spree_core-4.0.1 app/models/spree/image.rb
spree_core-4.0.0 app/models/spree/image.rb
spree_core-4.0.0.rc3 app/models/spree/image.rb
spree_core-4.0.0.rc2 app/models/spree/image.rb
spree_core-4.0.0.rc1 app/models/spree/image.rb
spree_core-4.0.0.beta app/models/spree/image.rb