I have the following route file:
Rails.application.routes.draw do
namespace :api, constraints: { subdomain: 'api' }, path: '/' do
namespace :v1 do
post 'user_token' => 'user_token#create'
end
end
end
With that, I expect to be able to make a POST request like:
But this request gives me the following error:
NameError: uninitialized constant API::V1::User
It seems like, knock are trying to access my model User from the same namespace where the controller UserTokenController is. But my model User is not namespaced:
class User < ApplicationRecord
has_secure_password
#...
end
My user_token_controller.rb
module API
module V1
class UserTokenController < Knock::AuthTokenController
end
end
end
Ruby Version: 2.3.2
Rails Version: 5.0.0.1
What I am missing?
Today I noticed that using a latest published version (2.0) gives me the error.
gem 'knock', '~> 2.0' # wont work
But if I setup to get the gem from github, like:
gem 'knock', github: 'psantos10/knock', branch: 'master'
Its works!
@psantos10 this has been fixed in #95 thanks to @albertobajo. I'll release a new version soon. In the meantime, using master works.
@nsarno I am using master branch now. And its working.
Most helpful comment
@nsarno I am using
masterbranch now. And its working.