1

I would like to remove a key/value from a nested hash in my params.

My params are:

Parameters: {"utf8"=>"✓", "q"=>{"upward_trending"=>"", "downward_trending"=>"", "name_cont"=>"test", "category_id_in"=>["1", ""], "country_eq"=>"", "end_date_gteq"=>"", "end_date_lteq"=>""}, "commit"=>"Filter", "type"=>"Dailyd eal"} 

I would like to remove name_cont from the q hash.

I am able to remove the full hash by doing:

request.query_parameters.except(:q) 

or

params.except(:q) 

But everytime I try anything like:

except(:q[:name_cont]) except("name_cont") except([:q][:name_cont]) 

I get errors.

Any ideas?

1 Answer 1

3

You should try

request.query_parameters[:q].except(:name_cont) # or params[:q].except(:name_cont) 

You can use except! also if you want in-place modification.

Sign up to request clarification or add additional context in comments.

1 Comment

Which method you used? except or except!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.