rails

https://github.com/rails/rails

Ruby

Ruby on Rails

ActionController::Parameters#to_hash

Returns a safe <tt>Hash</tt> 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 unfiltered parameters to hash

  safe_params = params.permit(:name)
  safe_params.to_hash # => {"name"=>"Senjougahara Hitagi"}

Source | Google | Stack overflow

Edit

git clone [email protected]:rails/rails.git

cd rails

open actionpack/lib/action_controller/metal/strong_parameters.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActionController--Parameters-to_hash-for-pr


# Commit to git

git add actionpack/lib/action_controller/metal/strong_parameters.rbgit commit -m "better docs for ActionController::Parameters#to_hash"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActionController--Parameters-to_hash-for-pr

hub pull-request


# Celebrate!