Rails设计禁用或删除用户注册但保留用户编辑路径

时间:2015-07-17 17:32:13

标签: ruby-on-rails ruby devise

我想禁用用户注册路径并保留用户编辑路径。我使用了本指南gulp-jshint: How to fail the build?

但我收到此错误

 ActionController::UnknownFormat at /users.55840776527573104d0c0000
ActionController::UnknownFormat

表单生成错误的网址,应该是那样的

/users/55840776527573104d0c0000 

查看

<%= form_for(resource, as: resource_name, url: user_registration_path(resource), html: { method: :patch}) do |f| %>


<%= f.submit "Update"%>

的routes.rb

 devise_for :users, :skip => [:registrations]
  as :user do
    get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
    patch'users' => 'devise/registrations#update', :as => 'user_registration'
  end

如何解决?

1 个答案:

答案 0 :(得分:3)

此问题的解决方法是将:id添加到routes.rb - patch

devise_for :users, :skip => [:registrations]
  as :user do
    get 'users/edit' => 'devise/registrations#edit', :as => 'edit_user_registration'
    patch'users/:id' => 'devise/registrations#update', :as => 'user_registration'
  end

找到解决方案here