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.
This commit is contained in:
Christoph Haas 2013-08-07 00:18:20 +02:00
parent 88dfb33721
commit 76d19f7e78
3 changed files with 14 additions and 8 deletions

View file

@ -4,7 +4,9 @@ class Screenshot < ActiveRecord::Base
# 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