0
我尝试做一个滑轨服务器看跌我得到这个错误: “send_request_with_body”:未定义的方法“bytesize”为#(NoMethodError) 这是Ruby代码:使红宝石机械化看跌期权和轨道服务器
agent = Mechanize.new
agent.basic_auth('[email protected]', '12345678')
a = agent.put('http://localhost:3000/thermostats/26.json',{ "thermostat[serial]" => "1", "thermostat[temperature]" => 50, "thermostat[humidity]" => 122222, "thermostat[user_id]" => 6 })
,这是你想要做的控制器的工作关李·贾维斯的回答的代码把
# 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
阅读#put的文件,第二个参数应该是一个字符串,而不是一个哈希:https://github.com/sparklemotion/mechanize/blob/master/lib/mechanize.rb#L533 –
什么我应该放入“实体”吗?, 是否是控制器的名称? – user2994005
你有没有想出答案? –