我正在使用 Angularjs 制作编辑对象表单,而 Ruby on Rails 4 是我的后端。我收到以下错误,看不到调试它的正确方法:
Started PUT "/albums/52109834e9c88c3292000001" for 127.0.0.1 at 2013-08-24 17:24:37 +0400
Overwriting existing field email.
Processing by AlbumsController#update as JSON
Parameters: {"_id"=>{}, "title"=>"Sacred Circuits"}
MOPED: 127.0.0.1:27017 QUERY database=aggregator_front_development collection=users selector={"$query"=>{"_id"=>"520bd6cbe9c88ca789000001"}, "$orderby"=>{:_id=>1}} flags=[:slave_ok] limit=-1 skip=0 batch_size=nil fields=nil (0.7932ms)
Completed 500 Internal Server Error in 63ms
ArgumentError (wrong number of arguments (2 for 0..1)):
app/controllers/albums_controller.rb:18:in `update'
第 18 行是更新函数,它没有参数。我正在从 Angularjs 表单发送对象来更新它。 专辑控制器.rb:
class AlbumsController < ApplicationController
respond_to :json, :js
def index
respond_with Album.all
end
def show
respond_with Album.find(params[:id])
end
def create
respond_with Album.create(params[:album])
end
def update
respond_with Album.update(params[:id],params[:album])
end
def destroy
respond_with Album.destroy(params[:id])
end
private
def album_params
params.require(:album).permit(:title)
end
end
我了解,ArgumentError(参数数量错误(0..1 为 2))的意思是,但不知道在哪里寻找真正的参数发送。如何调试这种情况?