Added missing jbuilder

This was the reason why JSON output was incorrectly formatted.
This commit is contained in:
Christoph Haas 2024-08-05 16:19:32 +02:00
parent 7fdd1332b7
commit 890906929f
3 changed files with 5 additions and 5 deletions

View file

@ -41,7 +41,7 @@ gem 'jquery-rails'
gem 'turbolinks', '~> 5' gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
#gem 'jbuilder', '~> 2.5' gem 'jbuilder', '~> 2.12'
# Use Redis adapter to run Action Cable in production # Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 3.0' # gem 'redis', '~> 3.0'

View file

@ -190,6 +190,9 @@ GEM
rdoc (>= 4.0.0) rdoc (>= 4.0.0)
reline (>= 0.4.2) reline (>= 0.4.2)
jaro_winkler (1.6.0) jaro_winkler (1.6.0)
jbuilder (2.12.0)
actionview (>= 5.0.0)
activesupport (>= 5.0.0)
jquery-rails (4.6.0) jquery-rails (4.6.0)
rails-dom-testing (>= 1, < 3) rails-dom-testing (>= 1, < 3)
railties (>= 4.2.0) railties (>= 4.2.0)
@ -513,6 +516,7 @@ DEPENDENCIES
guard-minitest guard-minitest
guard-rails guard-rails
image_processing image_processing
jbuilder (~> 2.12)
jquery-rails jquery-rails
listen (~> 3.5) listen (~> 3.5)
mini_magick mini_magick

View file

@ -3,27 +3,23 @@ class JsonController < ApplicationController
def package def package
expires_in 1.hours, public: true expires_in 1.hours, public: true
@p = Package.find_by_name! params[:name] @p = Package.find_by_name! params[:name]
render json: @p
end end
# JSON information on all packages # JSON information on all packages
def packages def packages
expires_in 1.days, public: true expires_in 1.days, public: true
@p = Package.all @p = Package.all
render json: { packages: @p }
end end
# JSON information on all screenshots # JSON information on all screenshots
def screenshots def screenshots
expires_in 1.days, public: true expires_in 1.days, public: true
@s = Screenshot.approved.includes(:package) @s = Screenshot.approved.includes(:package)
render json: { screenshots: @s }
end end
# JSON list of packages that do not have screenshots # JSON list of packages that do not have screenshots
def packages_without_screenshots def packages_without_screenshots
expires_in 1.hours, public: true expires_in 1.hours, public: true
@p = Package.without_screenshots.all @p = Package.without_screenshots.all
render json: { packages: @p }
end end
end end