How to get only query string in Rails route?
I use this route
match "/v1/:method" => "v1#index" My intention here is to grab the api method name and then send a request to this method inside the controller.
def index self.send params[:method], params end I figured this would lead to sending other parameters as an argument to the method, but that didn't work. So my question is how to pass non-method parameters to the query string?
#query_parameters does exactly what you want:
request.query_parameters It is also the most efficient solution, because it does not create a new hash, as others do.
Stolen from work colleagues. I find this a bit more reliable solution, as it will work even if there are changes in the path parameters:
params.except(*request.path_parameters.keys) I solved this problem by following these steps:
params.except("method","action","controller")