The actual solution is to enable Rack Cache (in config/environments/development.rb
):
config.action_dispatch.rack_cache = {
metastore: 'file:tmp/cache/rack/meta',
entitystore: 'file:tmp/cache/rack/body'
}
And to be conscious that every image.width
, image.height
, etc... will actually call a convert
command. So if you want to have this info often, it's better to store it along your model:
create_table "images", force: true do |t|
# ...
t.string "image_uid"
t.string "image_name"
t.integer "image_height"
t.integer "image_width"
end
And in your model:
before_save :update_image_fields
def update_image_fields
if image
self.image_width = image.width
self.image_height = image.height
else
self.image_width = self.image_height = 0
end
true
end