I need to add a header to my hash that I convert to JSON.
In my controller I have:
render json: @rates
With @rates
being a hash that looks like this:
{:rates=>[{:service_name=>"Standard", :service_code=>"FU",
:total_price=>"1100", :currency=>"USD", :min_delivery_date=>"2016-03-11
08:00:00 +0000", :max_delivery_date=>"2016-03-16 06:59:59 +0000"},
{:service_name=>"Priority", :service_code=>"FU", :total_price=>"2300",
:currency=>"USD", :min_delivery_date=>"2016-03-08 08:00:00 +0000",
:max_delivery_date=>"2016-03-09 07:59:59 +0000"},
{:service_name=>"Expedited", :service_code=>"FU", :total_price=>"1420",
:currency=>"USD", :min_delivery_date=>"2016-03-09 08:00:00 +0000",
:max_delivery_date=>"2016-03-10 07:59:59 +0000"}]}
The JSON format is perfect, but I believe I need a header for it for the API to get the rates from me. I saw "Render JSON with header", but I don't get it.
I need to add:
Content-Type: application/json
Can I just add this to my hash as another key/value pair? Or do I have to do some special header value?