I have a Controller:
class ThingController < ActionController
respond_to :json
def create
puts "CREATE " + params.inspect
end
end
and a test:
require "spec_helper"
describe "/thing" do
context "create" do
it "should get params" do
params = {"a" => "b", "c" => ["d"], "e" => [], "f"=>"",
"g"=>nil, , "controller" => "NOPE", "action" => "NOPE"}
post uri, params
end
end
end
When I run this, the following is logged:
CREATE {"a"=>"b", "c"=>["d"], "action"=>"create", "controller"=>"thing"}
My questions are:
- where did
e
go? I would expect it to deserialize to an empty array, not to nothing at all. - why are the
action
andcontroller
params being mixed into this? Aren't the body and the rails internals completely separate concerns? - Because of this, my
action
andcontroller
JSON fields were over-written. How would I access these? - Is this therefore not the right way to accept JSON?
I'm new to Rails, but I have done a lot of Django.