我接管了其他人的Rails项目,并且对HTTP请求有个疑问。HTTP请求 - Ruby on Rails
它似乎我应该能够通过HTTP请求传递参数,我只是不确定如何。例如:rake routes
显示
PUT /auction2s/:id(.:format) auction2s#update
这似乎符合这个功能
# PUT /auction2s/1
# PUT /auction2s/1.json
def update
@auction2 = Auction2.find(params[:id])
print "Hello World"
respond_to do |format|
if @auction2.update_attributes(params[:auction2])
format.html { redirect_to @auction2, notice: 'Auction2 was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.json { render json: @auction2.errors, status: :unprocessable_entity }
end
end
end
但我想不出我需要传递给,比如URL,改变
id=18445&done=true
进入该功能。
有什么想法?功能结构是否正确?我只需要以Ruby格式传递请求,而不是通过浏览器或AJAX(我正在尝试)?
首先,你的'routes'文件说'PUT' req被设置为'auction1s',你提到的代码是关于'auction2s'的? –
@NeerajT太好了。他的编辑可能会让你免于失去所有的代表权:http://stackoverflow.com/help/whats-reputation(请参阅“你失去声望时”部分的#5)。编程问题可能会令人沮丧,但它通常是一个好主意(阅读:对你有利),让你的问题不受挫折。 –
我的错 - 我只是想让你们明白我真的失去了什么,所以当我构建它的时候,我不会假设我是如何构造事物的。 –