instance method encode_params

Ruby on Rails 3.2.22.5

Since v3.0.20 Last seen in v3.2.22.5 Private

Available in: v3.0.20 v3.1.12 v3.2.22.5

Signature

encode_params(params)

TODO: Validate that the characters are UTF-8. If they aren’t, you’ll get a weird error down the road, but our form handling should really prevent that from happening

Parameters

params req
Source
# File actionpack/lib/action_dispatch/http/parameters.rb, line 47
      def encode_params(params)
        return params unless "ruby".encoding_aware?

        if params.is_a?(String)
          return params.force_encoding("UTF-8").encode!
        elsif !params.is_a?(Hash)
          return params
        end

        params.each do |k, v|
          case v
          when Hash
            encode_params(v)
          when Array
            v.map! {|el| encode_params(el) }
          else
            encode_params(v)
          end
        end
      end

Defined in actionpack/lib/action_dispatch/http/parameters.rb line 47 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActionDispatch::Http::Parameters

Type at least 2 characters to search.

↑↓ navigate · open · esc close