I have the following strong params in my developers_controller named location_params
def location_params
params.require(:location).permit(:country, {:ads_attributes => [:remote, :days]})
end
When I set a debug breakpoint in the code, to test on how to use the fields :remote and :days, I have to use the following code to get :remote and :days in the console.
location_params[:ads_attributes]["2"][:remote]
I do not understand and know how to remove this ["2"]
index. I would like to select the params
with the following code location_params[:ads_attributes][:remote]
This is the result in the console from location_params[:ads_attributes]
<ActionController::Parameters
{"0"=><ActionController::Parameters {} permitted: true>,
"1"=><ActionController::Parameters {"days"=>"12"} permitted: true>,
"2"=><ActionController::Parameters {"remote"=>"1"} permitted: true>}
permitted: true>
I did make a search on stackoverflow and I could not find a solution to this specific issue with the index.