From 890906929f0b4070de94dc67e67fa26edaee3833 Mon Sep 17 00:00:00 2001 From: Christoph Haas Date: Mon, 5 Aug 2024 16:19:32 +0200 Subject: [PATCH] Added missing jbuilder This was the reason why JSON output was incorrectly formatted. --- Gemfile | 2 +- Gemfile.lock | 4 ++++ app/controllers/json_controller.rb | 4 ---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 0adf279..d4f8418 100644 --- a/Gemfile +++ b/Gemfile @@ -41,7 +41,7 @@ gem 'jquery-rails' gem 'turbolinks', '~> 5' # 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 # gem 'redis', '~> 3.0' diff --git a/Gemfile.lock b/Gemfile.lock index 7335426..74f3a52 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -190,6 +190,9 @@ GEM rdoc (>= 4.0.0) reline (>= 0.4.2) jaro_winkler (1.6.0) + jbuilder (2.12.0) + actionview (>= 5.0.0) + activesupport (>= 5.0.0) jquery-rails (4.6.0) rails-dom-testing (>= 1, < 3) railties (>= 4.2.0) @@ -513,6 +516,7 @@ DEPENDENCIES guard-minitest guard-rails image_processing + jbuilder (~> 2.12) jquery-rails listen (~> 3.5) mini_magick diff --git a/app/controllers/json_controller.rb b/app/controllers/json_controller.rb index 4928314..b9959ae 100644 --- a/app/controllers/json_controller.rb +++ b/app/controllers/json_controller.rb @@ -3,27 +3,23 @@ class JsonController < ApplicationController def package expires_in 1.hours, public: true @p = Package.find_by_name! params[:name] - render json: @p end # JSON information on all packages def packages expires_in 1.days, public: true @p = Package.all - render json: { packages: @p } end # JSON information on all screenshots def screenshots expires_in 1.days, public: true @s = Screenshot.approved.includes(:package) - render json: { screenshots: @s } end # JSON list of packages that do not have screenshots def packages_without_screenshots expires_in 1.hours, public: true @p = Package.without_screenshots.all - render json: { packages: @p } end end