2017-02-22 12 views
0

シンプルなフォームでAjaxの更新アクションを作成しようとしていますが、なぜブラウザが「パッチ」の代わりに「取得」要求を出したのかわかりません。私の見解ではRails単純なフォームのajax投稿:なぜGETリクエストですか?

私はcertificate_webexメソッドを持っているコントローラで

= simple_form_for current_user, url: certificate_webex_employee_path(current_user), remote: true, html: { class: 'edit-profile' }, defaults: { label: false } do |f| 
      .form-body 
      .form-group.row 
       .col-md-12{style: 'color: black'} 
       = f.input_field :webex_certification_code, class: "form-control" 

マイroutes.rbを

resources :users, controller: 'employees', path: 'employees', as: 'employees', only: [:index, :edit, :update, :show, :destroy] do 
    get :performance, on: :collection 
    member do 
     patch :certificate_webex 
    end 
    end 

そしてもちろんを持っています。

私がアクションを提出すると、なぜ「リクエストメソッド:GET」ですか? certificate_webexメソッドがフォームから呼び出されていません。私は

=form_for current_user, url: certificate_webex_employee_path(current_user), method: :patch, remote: true, html: { class: 'edit-profile' }, defaults: { label: false } do |f| 
= f.text_field :webex_certification_code, class: "form-control" 
+0

'f.submit'ボタンをクリックするかjavascript/jqueryでカスタマイズしたボタンをクリックしてフォームを送信しますか? – rogelio

答えて

0

でもしてみてください

編集

は、私は、ドキュメントのform_for simple_form_for宝石が、デフォルトのレールを使用していないのform_for

:method => :patch 

方法を指定してくださいここをクリックしてください:http://api.rubyonrails.org/classes/ActionView/Helpers/FormHelper.html

+0

同じ、常に:私がフォームを使用しても取得して指定します。 –

+0

あなたのルートでは、[:index、:edit、:update、:show、:destroy]だけにパッチを追加する必要がありますか? – Brad

関連する問題