Reputation: 815
This line in my users index view:
<%= simple_form_for current_user, :url => user_change_client_path,
:method => :patch,
:id => current_user.id do |f| %>
generates the following error:
No route matches {:action=>"change_client", :controller=>"users"} missing required keys: [:user_id]
I have the change_client action defined in my controller. In my routes.rb I have:
resources :users, only: [:index] do
patch 'change_client'
patch 'approve'
end
Rake routes shows:
user_change_client PATCH /users/:user_id/change_client(.:format) users#change_client
user_approve PATCH /users/:user_id/approve(.:format) users#approve
What am I doing wrong that's causing the error?
Upvotes: 0
Views: 2502
Reputation: 767
Your route below:
user_change_client PATCH /users/:user_id/change_client(.:format)
Requires a user_id
parameter. When you call this helper, pass your current user to it like so:
user_change_client_path(current_user)
Upvotes: 1