Work around Rails expectations that forbid dots in parameters

This commit is contained in:
Christoph Haas 2021-02-21 11:12:16 +01:00
parent 75083eed6f
commit b6e4bd8a99
2 changed files with 11 additions and 5 deletions

View file

@ -112,10 +112,14 @@ class PackagesController < ApplicationController
# if @invalid_images…
# ' #{image.image_file_name} (#{image.errors[:image].join(' and ')})
respond_to do |format|
format.html { redirect_to package_path }
# Rails does not allow dots in the URL. So we cannot use the 'respond_to'
# and 'format' ways to handle parameters. Instead the 'returns' parameters
# is set in routes.rb to signal that this method was called by AJAX.
if params[:returns] == :json
# TODO: send all_errors back as JSON and make Javascript display it in #messages
format.json { render :json => true }
render :json => true
else
redirect_to package_path
end
# render :details