debshots/app/models/screenshot.rb
Christoph Haas 76d19f7e78 Unsuccessful attempt to properly eager load screenshots.
Currently the virtual attribute "image_url" in the screenshots model
apparently runs one SQL query each to get the packages data.
2013-08-07 00:18:20 +02:00

12 lines
425 B
Ruby

class Screenshot < ActiveRecord::Base
belongs_to :package
# Return the URL to this screenshot.
# size: 'small' (thumbnail) or 'large' (full-size)
# (If possible serve the screenshots statically from the web server.)
#attr_accessor :image_url
def image_url(size)
# TODO: Prevents proper eager loading somehow...
"/screenshots/#{self.package.name[0]}/#{self.package.name}/#{self.id}_#{size}.png"
end
end