I try make a put in a rails server I get this error: 'send_request_with_body': undefined method 'bytesize' for # (NoMethodError) this is the ruby code:
agent = Mechanize.new
agent.basic_auth('user@gmail.com', '12345678')
a = agent.put('http://localhost:3000/thermostats/26.json',{ "thermostat[serial]" => "1", "thermostat[temperature]" => 50, "thermostat[humidity]" => 122222, "thermostat[user_id]" => 6 })
and this is the code of the controller you want to do put
# PATCH/PUT /thermostats/1.json
def update
respond_to do |format|
if @thermostat.update(thermostat_params)
@thermostat.history_thermostats.create(temperature:@thermostat.temperature, humidity: @thermostat.humidity, energy: @thermostat.energy)
format.html { redirect_to @thermostat, notice: 'Thermostat was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: 'edit' }
format.json { render json: @thermostat.errors, status: :unprocessable_entity }
end
end
end