Reputation: 311
I use devise and devise token auth gems. I want to enter edit user path
<%= link_to "Edit profile", edit_user_registration_path(current_user.id) %>
But got an error wrong number of arguments (given 1, expected 0) on this part of code def authenticate_user!
def authenticate_user!
if user_signed_in?
super
else
redirect_to new_user_session_path
end
end
My routes
Rails.application.routes.draw do
devise_for :users
get 'demo/members_only', to: 'payments#members_only'
# token auth routes available at /api/v1/auth
namespace :api do
scope :v1 do
mount_devise_token_auth_for 'User', at: 'auth'
end
end
resources :payments
root "payments#index"
end
Now Idea how to solve it.
Upvotes: 0
Views: 1079
Reputation: 311
Looks like devise_token_auth redefines basic devise helpers that's why it doesn't work.
Upvotes: 1
Reputation: 8518
If the current_user
is be used, you don't need to pass it separately. Devise will use it, if no argument is provided.
<%= link_to "Edit profile", edit_user_registration_path %>
What also should work is, if you pass the user record, instead of the id
:
<%= link_to "Edit profile", edit_user_registration_path(current_user) %>
Upvotes: 0
Reputation: 17834
You don't need to pass id
of the current user, devise takes current user object from the session, just do this and you are good to go.
<%= link_to "Edit profile", edit_user_registration_path %>
Hope that helps!
Upvotes: 0