Skip to content

Commit c66a27a

Browse files
Add :tab and :booleanType to permit call in view
** Why are these changes being introduced: * We are building links to the different result tabs in the _source_tabs view partial via the params.permit() method, but that list is not comprehensive of the params that the SearchController is then adding. This mismatch between permitted and used params is generating messages in the logs about unpermitted parameters (two of them for every page load, one for each tab) ** Relevant ticket(s): * https://mitlibraries.atlassian.net/browse/use-94 ** How does this address that need: * This adds the :tab and :booleanType values to the list of permitted parameters for building those links, which results in those log messages no longer being written. ** Document any side effects to this change: There are a few different ways we might resolve this behavior - I've chosen the simplest to adopt now, but it may not be the best option long term. For example, if next week we expand the SearchController to add another new parameter, that would need to be added to this partial or we'll have another round of log messages. Other options include: - Explicitly building the links by including every relevant parameter, i.e. results_path(q: params[:q], per_page: params[:per_page]... - this would limit the need to keep this partial in sync with the controller. - Choosing a different way of handling values like :booleanType that does not rely on manipulating the params object in the midst of responding to a page request. This is probably the cleanest option, but means refactoring more of the application, and a larger level of effort. Note that I originally tried to resolve this condition via a before_action lifecycle hook in the SearchController, explicitly making :tab and :booleanType params permitted. That doesn't work because the partial also calls .permit, which acts independently of anything the controller does or doesn't do.
1 parent 9267108 commit c66a27a

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/views/search/_source_tabs.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<!-- Tab Navigation -->
22
<div id="tabs" class="tab-navigation top-space">
3-
<%= link_to "Primo", results_path(params.permit(:q, :per_page, :page).merge(tab: 'primo')),
3+
<%= link_to "Primo", results_path(params.permit(:q, :per_page, :page, :booleanType, :tab).merge(tab: 'primo')),
44
class: "tab-link #{'active' if @active_tab == 'primo'}",
55
data: { turbo_frame: "search-results", turbo_action: "advance" } %>
6-
<%= link_to "TIMDEX", results_path(params.permit(:q, :per_page, :page).merge(tab: 'timdex')),
6+
<%= link_to "TIMDEX", results_path(params.permit(:q, :per_page, :page, :booleanType, :tab).merge(tab: 'timdex')),
77
class: "tab-link #{'active' if @active_tab == 'timdex'}",
88
data: { turbo_frame: "search-results", turbo_action: "advance" } %>
99
</div>

0 commit comments

Comments
 (0)