Fix exception on error page when handling PG::AmbiguousColumn error.
Fix an exception on the error page when a controller index action raised an PG::AmbiguousColumn error because the model `search` method generated SQL with an ambiguous column reference. In this case the error page tried to generate data attributes for the <body> tag, but this failed because evaluating the `current_item` raised an exception again.
This commit is contained in:
@@ -264,9 +264,18 @@ module ApplicationHelper
|
||||
render "table_builder/table", table: table
|
||||
end
|
||||
|
||||
def body_attributes(current_user, params, current_item = nil)
|
||||
controller_param = params[:controller].parameterize.dasherize
|
||||
action_param = params[:action].parameterize.dasherize
|
||||
def body_attributes(current_user, params, current_item, exception)
|
||||
if exception
|
||||
controller_param = "static"
|
||||
action_param = "error"
|
||||
layout = nil
|
||||
extra_attributes = {}
|
||||
else
|
||||
controller_param = params[:controller].parameterize.dasherize
|
||||
action_param = params[:action].parameterize.dasherize
|
||||
layout = controller.class.send(:_layout)
|
||||
extra_attributes = current_item_data_attributes(current_item)
|
||||
end
|
||||
|
||||
{
|
||||
lang: "en",
|
||||
@@ -275,12 +284,12 @@ module ApplicationHelper
|
||||
data: {
|
||||
controller: controller_param,
|
||||
action: action_param,
|
||||
layout: controller.class.send(:_layout),
|
||||
layout: layout,
|
||||
"current-user-ip-addr": request.remote_ip,
|
||||
"current-user-save-data": CurrentUser.save_data,
|
||||
**current_user_data_attributes(current_user),
|
||||
**cookie_data_attributes,
|
||||
**current_item_data_attributes(current_item),
|
||||
**extra_attributes,
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
@@ -57,7 +57,7 @@
|
||||
<%= yield :html_header %>
|
||||
<%= raw Danbooru.config.custom_html_header_content %>
|
||||
</head>
|
||||
<%= tag.body **body_attributes(CurrentUser.user, params, @current_item) do %>
|
||||
<%= tag.body **body_attributes(CurrentUser.user, params, @current_item, @exception) do %>
|
||||
<%= render "news_updates/listing" %>
|
||||
|
||||
<header id="top" class="mb-4">
|
||||
|
||||
Reference in New Issue
Block a user