Project

General

Profile

Refactor #18214

Accept `params` as either ActionController::Parameters or Hash

Added by Dominic Cleal over 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
Rails
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

A few places in the codebase check the type of argument with is_a?(Hash) when accepting input from either params (via a controller) or manually constructed hashes, e.g.

  • Foreman::AccessControl.permissions_for_controller_action
  • ReportImporter#initialize
  • Role#allowed_to?
  • User#allowed_to?

In Rails 4.2, params is an ActionController::Parameters instance, but it's a subclass of Hash. In Rails 5, it no longer inherits from Hash (https://github.com/rails/rails/commit/14a3bd5) and so checks for is_a?(Hash) return false. The checks should permit either, as both plain hashes and params are passed around in Foreman.

Associated revisions

Revision 15c7ce27 (diff)
Added by Dominic Cleal over 5 years ago

fixes #18214 - accept `params` as AC::Parameters or Hash

In Rails 5, ActionController::Parameters no longer inherits from Hash
and so type checks for params.is_a?(Hash) now return false and should
accept either. (Rails commit 14a3bd5.)

History

#1 Updated by The Foreman Bot over 5 years ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4221 added

#2 Updated by Dominic Cleal over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#3 Updated by Dominic Cleal over 5 years ago

  • Legacy Backlogs Release (now unused) set to 209

Also available in: Atom PDF