Hi i facing error here,
I have two model called User and Admin
and now currently want to add api routes
routes.rb
devise_scope :user do
post 'api/v1/users/forgot_password' => "api/v1/users#forgot_password"
end
but when try to call
@user.send_reset_password_instructions
got this error
RuntimeError (Could not find a valid mapping for
try to debug call Devise.mappings inside that routes it always is
{:admin=>#<Devise::Mapping:0x007fa7444181e0 @scoped_path="admins", @singular=:admin, @class_name="Admin", @klass=#<Devise::Getter:0x007fa7443fbd10 @name="Admin">, @path="admins", @path_prefix=nil, @sign_out_via=:delete, @format=nil, @router_name=nil, @failure_app=Devise::FailureApp, @controllers={:sessions=>"devise/sessions", :passwords=>"devise/passwords"}, @path_names={:registration=>"", :new=>"new", :edit=>"edit", :sign_in=>"sign_in", :sign_out=>"sign_out", :password=>"password"}, @modules=[:database_authenticatable, :rememberable, :recoverable, :validatable, :trackable], @routes=[:session, :password], @used_routes=[:session, :password], @used_helpers=[:session, :password]>}
is it this mappings that show me an error because its not user.. how can i solve this?
Probably you don't have devise_for in your routes?
devise_scope won't work if devise_for isn't given. I added
devise_for :users, only: []
to my routes, to fix this.
@pmk1c is correct. Check if you have the devise_for call. If you do and it still don't work please comment here that we will reopen. Thank you for reporting.
Most helpful comment
Probably you don't have
devise_forin your routes?devise_scopewon't work ifdevise_forisn't given. I addedto my routes, to fix this.