Q:

RSpec doesn't return Hash field to Controller

So I'm running a #create test in my Rails API, but somehow one field in the Factory which is a Hash doesn't reach the Controller for an INSERT. 
Factory
    factory :child do
        id 5
        type "type1"
        vars { var1: 1, var2: 2 }
        values { value1: 1, value2: 2 }
    end

Test
    it "creates child with associated id" do
        Rails::logger.info "Testing CREATE"
        child = FactoryGirl.build(:child).attributes
        Rails::logger.info "INITIAL:"
        Rails::logger.info child
        post :create, :parent => @parent_id, :child => child
        expect(response).to have_http_status(201)
    end

Controller Action
def create
    @parent = Parent.find(params[:parent_id])
    @child = @parent.childs.build(child_params)

    if @child.save
      render json: @child, status: 201
    else
      render json: { error: "404: Not Found" }.to_json, status: 404 #just to know, this error will be changed
    end
end

(...) some code here

def child_params
  params.require(:child).permit(:id, :type, :parent_id) #here I've also tried to include :vars, :value unsuccessfully
end

Result
D, [2015-01-08T20:02:19.016182 #76314] DEBUG -- :   SQL (0.9ms)  
INSERT INTO "childs" ("id", "type", "parent_id", "created_at", "updated_at") 
VALUES ($1, $2, $3, $4, $5) RETURNING "id"  
[["id", 1], ["type", "type1"], ["parent_id", 1], ["created_at", "2015-01-08 20:02:19.010801"], ["updated_at", "2015-01-08 20:02:19.010801"]]

As you can see, the vars and values hashes are not read by the Controller.  The RSpec test reads them fine:
I, [2015-01-08T20:02:18.989104 #76314]  INFO -- : 
{"id"=>1, "type"=>"type1", "vars"=>{"var1"=>"1", "var2"=>"2"}, "values"=>{"value1"=>"1", "value2"=>"2"}, "created_at"=>nil, "updated_at"=>nil, "parent_id"=>nil}

Am I missing something? 

A:

At the moment strong_params doesn't allow (AFAIK, and according to this) to permit hashes with unknown keys inside so you need to do in your strong params something like, if you know the keys
def child_params
  params.require(:sth).permit(:id, :type, :parent_id, vars: [:var1, :var2], values: [:value1, :value2]) 
end

or simply do
def child_params
  params.require(:sth).permit! 
end

Here's live from my console
[7] pry(#<Admin::SampleController>)> params.require(:sth).permit(:type, vars: [:var1, :var2])
Unpermitted parameters: id, values, created_at, updated_at, parent_id
=> {"type"=>"type1", "vars"=>{"var1"=>"1", "var2"=>"2"}}
[8] pry(#<Admin::SampleController>)> params.require(:sth).permit(:type, vars: [[]])
Unpermitted parameters: var1, var2
Unpermitted parameters: id, values, created_at, updated_at, parent_id
=> {"type"=>"type1", "vars"=>{}}
[9] pry(#<Admin::SampleController>)> params.require(:sth).permit! 
=> {"id"=>1,
 "type"=>"type1",
 "vars"=>{"var1"=>"1", "var2"=>"2"},
 "values"=>{"value1"=>"1", "value2"=>"2"},
 "created_at"=>nil,
 "updated_at"=>nil,
 "parent_id"=>nil}

