Flowdock
method

to_hash

Importance_1
Ruby on Rails latest stable (v5.2.3) - 0 notes - Class: Parameters
to_hash() public

Returns a safe Hash representation of the parameters with all unpermitted keys removed.

params = ActionController::Parameters.new({
  name: "Senjougahara Hitagi",
  oddity: "Heavy stone crab"
})
params.to_hash
# => ActionController::UnfilteredParameters: unable to convert unpermitted parameters to hash

safe_params = params.permit(:name)
safe_params.to_hash # => {"name"=>"Senjougahara Hitagi"}
Show source
Register or log in to add new notes.