2016-05-31 5 views
0

コントローラの「更新」アクションに提出する必要があるフォームがあります。代わりに "show"アクションが呼び出されており、 "update"アクションは実行されません。Railsは、更新アクションの代わりにアクションが呼び出されていることを示します。

マイルート:フォームがによって作成された

 evaluations GET /evaluations(.:format)    evaluations#index 
        POST /evaluations(.:format)    evaluations#create 
    new_evaluation GET /evaluations/new(.:format)   evaluations#new 
    edit_evaluation GET /evaluations/:id/edit(.:format)  evaluations#edit 
     evaluation GET /evaluations/:id(.:format)   evaluations#show 
        PATCH /evaluations/:id(.:format)   evaluations#update 
        PUT /evaluations/:id(.:format)   evaluations#update 
        DELETE /evaluations/:id(.:format)   evaluations#destroy 

action: "<%= evaluation_path %>", 
 
method: "patch" //I have tried both "post" and "put" as well

私のコントローラは、同様に有効な "更新" アクションを持っています。

+0

フォームは、リアクションコンポーネントに渡されるJavascriptオブジェクトからレンダリングされます。 – cmwall

+0

フォームコード全体、少なくともform_forまたはform_tagを表示してください。 – Leito

+0

form_forタグはありません。フォームは、JavascriptオブジェクトをReact Componentに渡すことによって作成され、React Componentはアクションとメソッドを設定します。 – cmwall

答えて

1

あなたは次のように、idまたはrecordに合格することを忘れないでください。また、

action: evaluation_path(@evaluation), method: "patch" 

actionキーを回避する方法:

button_to "Update", evaluation_path(@evaluation), method: "patch" 
+0

ありがとうございますが、これはまだ 'show'メソッドを呼び出します。 – cmwall

+0

@cmwall upadted answer –

1

は大文字で方法PATCHを試してみてください。ちょうど馬鹿。 HTTP動詞は、大文字と小文字を区別することが多く、大文字で表現されています。

関連する問題