设计编辑/更新配置文件不会做PATCH或PUT - 我总是得到GET

时间:2016-03-18 18:43:50

标签: ruby-on-rails ruby-on-rails-4 devise

我将Devise添加到我的rails应用程序中,一切正常,除非我尝试更改配置文件 - 我似乎可以使表单执行PUT或PATCH。

这是我的设置

我的edit.html.haml:

    = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :patch }) do |f|
  = devise_error_messages!
  .form-group
    %label.col-sm-2.control-label{:for => "inputName"} Name
    .col-sm-10
      = f.text_field :name, autofocus: true, placeholder: "Name", class: "form-control"
  .form-group
    %label.col-sm-2.control-label{:for => "inputEmail"} Email
    .col-sm-10
      = f.email_field :email, placeholder: "Name", type: "email", class: "form-control"
  .form-group
    = f.label :password, class: "col-sm-2 control-label"
    .col-sm-10
      = f.password_field :password, autocomplete: "off", placeholder: "Password", type: "password", class: "form-control"
  .form-group
    = f.label :password_confirmation, class: "col-sm-2 control-label"
    .col-sm-10
      = f.password_field :password_confirmation, autocomplete: "off", :placeholder => "Retype password", :type => "password", class: "form-control"
  .form-group
    = f.label :avatar, class: 'col-sm-2 control-label'
    .col-sm-10
      = f.file_field :avatar



  .form-group
    .col-sm-offset-2.col-sm-10
      %button.btn.btn-danger{:type => "submit"} Submit

我的routes.rb文件......我只有一行关于设计 - 在最顶端。

Rails.application.routes.draw do

  devise_for :users

rake routes:

                        Prefix Verb     URI Pattern                                                                 Controller#Action
          new_user_session GET      /users/sign_in(.:format)                                                    devise/sessions#new
              user_session POST     /users/sign_in(.:format)                                                    devise/sessions#create
      destroy_user_session DELETE   /users/sign_out(.:format)                                                   devise/sessions#destroy
             user_password POST     /users/password(.:format)                                                   devise/passwords#create
         new_user_password GET      /users/password/new(.:format)                                               devise/passwords#new
        edit_user_password GET      /users/password/edit(.:format)                                              devise/passwords#edit
                           PATCH    /users/password(.:format)                                                   devise/passwords#update
                           PUT      /users/password(.:format)                                                   devise/passwords#update
  cancel_user_registration GET      /users/cancel(.:format)                                                     devise/registrations#cancel
         user_registration POST     /users(.:format)                                                            devise/registrations#create
     new_user_registration GET      /users/sign_up(.:format)                                                    devise/registrations#new
    edit_user_registration GET      /users/edit(.:format)                                                       devise/registrations#edit
                           PATCH    /users(.:format)                                                            devise/registrations#update
                           PUT      /users(.:format)                                                            devise/registrations#update
                           DELETE   /users(.:format)                                                            devise/registrations#destroy

当我尝试通过表单更改配置文件时,即使该方法设置为PUT,我也会获得GET请求。我也尝试过PATCH。

EDIT 我不明白表单的网址是:

registration_path(resource_name)

当我做rake路线时,甚至没有列出。我没有收到任何错误,

1 个答案:

答案 0 :(得分:0)

愚蠢的我 - 在获得PUT表格标签之前,我有一个错位的表格标签发出了GET请求