0

current_user (デバイス) の単一のデータベースフィールドを更新しようとしています。

link_to ヘルパーだけでこれを行いたい:

<%= link_to "Grid", edit_user_registration_path(current_user, :project_view => "grid"), :method => :put %>

しかし、結果として常にエラーになるため、動作させることができません:

Routing Error

No route matches [PUT] "/users/edit.1"

Deviseの私のルート:

        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

ルーティングの何が問題になっていますか? カスタムの変更を加えずにdeviseを使用しています。

ありがとう!

4

1 に答える 1

1

間違ったパス ヘルパー:

$ rake routes
 new_user_registration    GET     ...  registrations#new
 cancel_user_registration GET     ...  registrations#cancel
 user_registration        POST    ...  registrations#create
 edit_user_registration   GET     ...  registrations#edit
             users        PUT     ...  registrations#update # You want this one
                          DELETE  ...  registrations#destroy

結果:

<%= link_to "Grid", users_path(:user => {:project_view => 'grid'}), :method => :put, :confirm => "Are you sure?" %>

特定のルートの更新:

<%= link_to "Grid", registration_path(resource_name, :user => {:project_view => 'grid'}), :method => :put, :confirm => "Are you sure?" %>
于 2013-01-31T12:04:42.300 に答える