我有两个使用Devise 3的模型。我的编辑和更新路由没有我期望的/:id,这导致我收到一个糟糕的PUT请求,如下所示。
Started PUT "/users.user" for 127.0.0.1 at 2014-06-11 11:11:46 -0400
Processing by RegistrationsController#update as
Completed 406 Not Acceptable in 4894.6ms (ActiveRecord: 2.4ms)
以下是路线
new_user_session GET /users/sign_in(.:format) sessions#new
user_session POST /users/sign_in(.:format) sessions#create
destroy_user_session DELETE /users/sign_out(.:format) sessions#destroy
user_password POST /users/password(.:format) passwords#create
new_user_password GET /users/password/new(.:format) passwords#new
edit_user_password GET /users/password/edit(.:format) passwords#edit
PUT /users/password(.:format) 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
这就是我的routes.rb看起来像
devise_for :users, :controllers => { :confirmations => "confirmations", registrations: "registrations", session: "sessions", passwords: "passwords" }
devise_scope :user do
authenticated :user do
root :to => 'appointments#index', as: :user_authenticated_root
get "/appointments", to: "appointments#index", as: :appointments
end
unauthenticated :user do
root :to => 'devise/registrations#new', as: :unauthenticated_root
end
match '/join' => 'devise/registrations#new'
end
我的表单是
<%= simple_form_for(resource, :as => resource_name, :url => user_registration_path(resource_name)) do |f| %>
<%= f.error_notification %>
我缺少什么来修复说/users/:id(.:format)等的路线?
答案 0 :(得分:0)
我认为应该这样做:
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>