I have a hash of nested params from which I'm trying to assign the value from a specific key to a variable in my controller:
@catch_all = params[:q][:search_box]
When trying to run the method where the above is located, I get an error "no implicit conversion of Symbol into Integer". The confounding part is that when I place similar code in a view, it returns the proper value.
<%= params[:q][:search_box] %>
returns "t" which is what I want in this example.
From what I've read it seems that in the controller, the params hash is being treated as an array and the string in [:search_box], not being an index integer, causes the exception. How can I assign "t" to the variable? More importantly, why am I able to get the value in the view and not the controller?
Edit: If it matters, [:q] is from the ransack search gem, which upon inspection of params[:q] is a string class.
Edit2: params[:q] is of the class ActionController::Parameters in the view
I had previously set up my saved search by saving the fullpath in the database and in my conversion to saving each field param individually, neglected to remove the conversion to fullpath in my view which was the culprit. params[:q][:search_box]
wound up working.