module ActionController::ParameterEncoding::ClassMethods
def param_encoding(action, param, encoding)
This is useful in the case where an application must handle data
but all other arguments will remain UTF-8 encoded.
The file_path parameter on the show action would be encoded as ASCII-8BIT,
end
end
@repositories = Repository.all
def index
end
@repo_name = params[:repo_name]
# params[:repo_name] remains UTF-8 encoded
@repo = Repository.find_by_filesystem_path params[:file_path]
def show
param_encoding :show, :file_path, Encoding::ASCII_8BIT
# This specifies that file_path is not UTF-8 and is instead ASCII_8BIT
class RepositoryController < ActionController::Base
You can specify a binary (ASCII_8BIT) parameter with:
If not specified the default is UTF-8.
Specify the encoding for a parameter on an action.
def param_encoding(action, param, encoding) @_parameter_encodings[action.to_s][param.to_s] = encoding end