FIX: Ensure 'tr' is called on a string. (#11853)

It depends on the route, but sometimes 'id' parameter can contain a
slug-like value and sometimes it is just an ID. This should work in
both cases.
This commit is contained in:
Dan Ungureanu 2021-01-27 10:43:33 +02:00 committed by GitHub
parent 60515547bc
commit 7be556fc19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -819,7 +819,7 @@ class ApplicationController < ActionController::Base
params[:slug] = params[:slug].first if params[:slug].kind_of?(Array)
params[:id] = params[:id].first if params[:id].kind_of?(Array)
@slug = (params[:slug].presence || params[:id].presence || "").tr('-', ' ')
@slug = (params[:slug].presence || params[:id].presence || "").to_s.tr('-', ' ')
render_to_string status: opts[:status], layout: opts[:layout], formats: [:html], template: '/exceptions/not_found'
end