Skip to content
This repository was archived by the owner on Aug 17, 2017. It is now read-only.
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

@developer88

Description

@developer88

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions