Work around Rails expectations that forbid dots in parameters
This commit is contained in:
parent
75083eed6f
commit
b6e4bd8a99
2 changed files with 11 additions and 5 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -27,8 +27,10 @@ Rails.application.routes.draw do
|
|||
# get 'package_reviews/:name' => 'packages#reviews', as: :package_reviews, name: /[^\/]+/
|
||||
get 'upload', to: redirect('/packages'), as: :upload_legacy # legacy upload form
|
||||
post 'uploadfile' => 'packages#legacy_uploadfile', name: /[^\/]+/
|
||||
get 'upload/:name' => 'packages#upload', as: :upload
|
||||
post 'upload/:name' => 'packages#upload_receive', as: :upload_receive
|
||||
get 'upload/:name' => 'packages#upload', as: :upload, name: /[^\/]+/
|
||||
get 'upload/:name/json' => 'packages#upload', as: :upload_json, name: /[^\/]+/, returns: :json
|
||||
post 'upload/:name' => 'packages#upload_receive', as: :upload_receive, name: /[^\/]+/
|
||||
post 'upload/:name/json' => 'packages#upload_receive', as: :upload_receive_json, name: /[^\/]+/, returns: :json
|
||||
# TODO: "get" is probably the wrong method to delete a screenshot
|
||||
get 'delete_screenshot/:id' => 'packages#delete_screenshot', as: :delete_screenshot
|
||||
patch 'update_screenshot_description/:id' => 'packages#update_screenshot_description', as: :update_screenshot_description
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue