You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 17, 2017. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 17, 2017. It is now read-only.
Nested array is empty in browser and in RSpec #206
Faced a strange problem or bug. I have a route with strong parameters method:
def st_params
params.permit([:id, logs: [], metric_ids: []])
end
Then i call it with, for example, rspec:
post some_path(format:json, metric_ids:[ [1,0,1], [5,1,4] ])
And when i call a st_params method there is no metric_ids param and i have received message in logs: Unpermitted parameters: metric_ids, but if i change st_params method like this:
def st_params
p = params.permit([:id, logs: [], metric_ids: []])
p[:metric_ids] = params[:metric_ids]
# or just p = params.permit!
p
end
Now, everything works fine in browser, but in rspec i have received nil value for metric_ids in any case :( I have not found any information about the problem in documentation. Maybe someone here will help me.
What version of Rails are you using? If you're using Rails 4 of later, you should submit your issues against rails/rails. This is a compatibility gem for Rails versions prior to 4.
Further, sending an array of array of integers is not something that is generally accommodated by Rails, which generally would represent such data using a hash.
Activity
kaspernj commentedon Mar 13, 2015
Try this fix:
Also submitted as PR here:
#221
thomasfedb commentedon Apr 30, 2015
What version of Rails are you using? If you're using Rails 4 of later, you should submit your issues against rails/rails. This is a compatibility gem for Rails versions prior to 4.
Further, sending an array of array of integers is not something that is generally accommodated by Rails, which generally would represent such data using a hash.
I'd suggest this be closed @fxn.