Rails4 で更新メソッド 'PATCH' で Angular ngResource を使用すると、サーバー エラーが発生します。
ActionController::ParameterMissing (param not found: page):
app/controllers/json_api/pages_controller.rb:39:in `filter_page_params'
app/controllers/json_api/pages_controller.rb:17:in `update'
window.app.factory 'Page', ($resource) ->
...
ReStFull: ( ->
return $resource('/json/pages/:id', {id: '@id'}, {update: {method: 'PATCH'}})
)
PUT のみが機能します。
私の Rails4 コントローラ アクションは次のようになります。
def update
if @page.update_attributes(filter_page_params)
render json: @page
else
render nothing: true, status: 400
end
end
強力なパラメーターのプライベート関数:
def filter_page_params
params.require(:page).permit(:parent_id, :name, :grid_layout_id)
end
更新時にプリロード フックがあり、@page が DB から既にロードされています。
angular がリクエストを中断する原因を知っている人はいますか?
助けていただければ幸いです。よろしく、アレックス