Fix 404 for missing package
This commit is contained in:
parent
9a91229336
commit
3f0737c614
2 changed files with 10 additions and 9 deletions
|
|
@ -19,16 +19,17 @@ class PackagesController < ApplicationController
|
|||
# TODO: Get only screenshots visible to the user (admin or owner or approved)
|
||||
@package = Package.find_by(name: params[:name])
|
||||
|
||||
unless @package
|
||||
if @package.nil?
|
||||
@packagename = params[:name]
|
||||
render 'notfound'
|
||||
end
|
||||
render 'notfound', status: 404
|
||||
else
|
||||
|
||||
# The first page of screenshots (if there are multiple at all) shows the
|
||||
# first image twice as large. So the first page contains 5 images while
|
||||
# the second and further page contain 6 images.
|
||||
@page = params[:page]
|
||||
@screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: 6)
|
||||
# The first page of screenshots (if there are multiple at all) shows the
|
||||
# first image twice as large. So the first page contains 5 images while
|
||||
# the second and further page contain 6 images.
|
||||
@page = params[:page]
|
||||
@screenshots = screenshots_visible_to_user(@package).paginate(page: @page, per_page: 6)
|
||||
end
|
||||
end
|
||||
|
||||
# Show upload form for new images
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ h1
|
|||
|
||||
p
|
||||
' I'm afraid but there is no package
|
||||
em =@package_name
|
||||
em =>@packagename
|
||||
' in the database. It may be that a package that is available
|
||||
' in your favorite Linux distribution is not listed here.
|
||||
' If you think this is an error then feel free to leave
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue