Return thumbnail or screenshot image upon 404 instead of exception

This commit is contained in:
Christoph Haas 2016-07-15 11:02:38 +02:00
parent a01d2c751c
commit 6a92292e9b

View file

@ -106,7 +106,7 @@ class PackagesController < ApplicationController
# If the package is found but has no screenshots then it also returns a # If the package is found but has no screenshots then it also returns a
# dummy image along with status 404. # dummy image along with status 404.
def thumbnail def thumbnail
@package = Package.find_by!(name: params[:name]) @package = Package.find_by(name: params[:name])
unless @package unless @package
thumbnail404 thumbnail404
return return
@ -135,7 +135,7 @@ class PackagesController < ApplicationController
# If the package is found but has no screenshots then it also returns a # If the package is found but has no screenshots then it also returns a
# dummy image along with status 404. # dummy image along with status 404.
def screenshot def screenshot
@package = Package.find_by!(name: params[:name]) @package = Package.find_by(name: params[:name])
unless @package unless @package
screenshot404 screenshot404
return return