Skip to content
This repository has been archived by the owner on Aug 17, 2017. It is now read-only.

Bug fix : nested ActiveSupport::HashWithIndifferentAccess were not converted to ActionController::Params #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

thomasguillory
Copy link

There is a bug when params is including nested hashes. The following should raise an ActiveModel::ForbiddenAttributes exception but don't:

class PeopleController < ApplicationController
  def create
    # params = {people: [{name: 'John Connor'},{name: 'Sarah Connor'},...]}
    @people = Person.create params[:people]
    ...
  end
end

Explanation:

  1. request.parameters is first converted in ActiveSupport::HashWithIndifferentAccess and so for all nested hashes.

  2. Then ActionController::Parameters.new(request.parameters) should convert the params hash and nested ones to ActionController::Parameters.

    ==> The bug was that nested ActiveSupport::HashWithIndifferentAccess were not converted.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant