Nested parameters?
One thing that Rails trips up on quite frequently is nested parameters. Does this gem handle them?
Example 1
works in Rails, but accepts everything in the array
get '/', allows: [:id, :action, :relationships[ ] ] do
erb :index
end
Example 2
does not work in rails, but is the ideal
get '/', allows: [:id, :action, :relationships[ allows: [:id, name]] ] do
erb :index
end
Not currently, no. Though I don't know why we couldn't implement something like that.
Are you looking to nest :allows and :needs within each other? That might get complicated... but being able to just allow certain parts of nested parameters should be doable. I'm thinking something like this:
get '/', allows: [:id, :action, :relationships[:id, name]] do
erb :index
end
Which would allow only the :id and :name params inside of the :relationships param.
Not looking to nest :allows and :needs within each other, no; it feels like madness lies that way at anything past 2 levels.
That syntax makes sense. How do you feel about people abusing the system with the following or worse?
get '/', allows: [:id, :action, :relationships[:id, :name, :parents[:id, :name, :grandparents[:id, :name, :sisters[:id, :name]]]]] do
erb :index
end
I agree, that seems like chaos.
Seems pretty wild, but there's no reason it shouldn't work. We'd just have to implement it so we can recurse through nested arrays.