Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/54.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 设计:路由错误阻止新用户注册_Ruby On Rails_Devise - Fatal编程技术网

Ruby on rails 设计:路由错误阻止新用户注册

Ruby on rails 设计:路由错误阻止新用户注册,ruby-on-rails,devise,Ruby On Rails,Devise,我在Desive应用程序中键入新电子邮件、密码和密码确认。当我去实际注册时,我得到以下错误: 路由错误 没有与[POST]匹配的路线“/users/sign\u up” 请尝试运行rake routes,了解有关可用路由的更多信息 它看起来像是new\u registration\u path将您带到users/sign\u up,但它不知道(至少在收到帖子时)。我如何让它认识到这一点 下面是一些相关的代码位 以下是(可能)相关的路线。rb: devise_for :users resourc

我在Desive应用程序中键入新电子邮件、密码和密码确认。当我去实际注册时,我得到以下错误:

路由错误

没有与[POST]匹配的路线“/users/sign\u up”

请尝试运行
rake routes
,了解有关可用路由的更多信息

它看起来像是
new\u registration\u path
将您带到
users/sign\u up
,但它不知道(至少在收到帖子时)。我如何让它认识到这一点

下面是一些相关的代码位


以下是(可能)相关的
路线。rb

devise_for :users
resources :users
这是rake路由的输出:

        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
                         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
                         PUT    /users(.:format)               devise/registrations#update
                         DELETE /users(.:format)               devise/registrations#destroy
       static_pages_home GET    /static_pages/home(.:format)   static_pages#home
                   users GET    /users(.:format)               users#index
                         POST   /users(.:format)               users#create
                new_user GET    /users/new(.:format)           users#new
               edit_user GET    /users/:id/edit(.:format)      users#edit
                    user GET    /users/:id(.:format)           users#show
                         PUT    /users/:id(.:format)           users#update
                         DELETE /users/:id(.:format)           users#destroy
              businesses GET    /businesses(.:format)          businesses#index
                         POST   /businesses(.:format)          businesses#create
            new_business GET    /businesses/new(.:format)      businesses#new
         ed  it_business GET    /businesses/:id/edit(.:format) businesses#edit
                business GET    /businesses/:id(.:format)      businesses#show
                         PUT    /businesses/:id(.:format)      businesses#update
                         DELETE /businesses/:id(.:format)      businesses#destroy
                    root        /                              static_pages#home
以下是registrations/new.html.erb中的表格:

<%= form_for(resource, :as => resource_name, :url => new_registration_path(resource_name)) do |f| %>
    ...
<% end %>
resource_name,:url=>new_registration_path(resource_name))do | f |%>
...

我认为你应该使用
注册路径
而不是
新注册路径
,因为注册是通过
POST
请求
/user
执行的

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
   ...
<% end %>
resource_name,:url=>registration_path(resource_name))do | f |%>
...

我认为你应该使用
注册路径
而不是
新注册路径
,因为注册是通过
POST
请求
/user
执行的

<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
   ...
<% end %>
resource_name,:url=>registration_path(resource_name))do | f |%>
...