instance method
to_h
Ruby on Rails 4.2.9
Since v4.2.9Signature
to_h()
Returns a safe Hash representation of this parameter with all unpermitted keys removed.
params = ActionController::Parameters.new({ name: 'Senjougahara Hitagi', oddity: 'Heavy stone crab' }) params.to_h # => {} safe_params = params.permit(:name) safe_params.to_h # => {"name"=>"Senjougahara Hitagi"}
Source
# File actionpack/lib/action_controller/metal/strong_parameters.rb, line 164
def to_h
if permitted?
to_hash
else
slice(*self.class.always_permitted_parameters).permit!.to_h
end
end
Defined in actionpack/lib/action_controller/metal/strong_parameters.rb line 164
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActionController::Parameters