简体   繁体   中英

Rails Devise disable or remove user registration but keep user edit path

I want to disable user registration path and keep user edit path. I used this guide for devise Solution 2.

But I am getting this error

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

The form generates incorrect url, it should be like that

/users/55840776527573104d0c0000 

View

<%= 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

How to fix it?

Solution for this problem is to add :id into 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

Found solution here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM