Starting a fresh Rails 6 project and including Knock:Authenticable results in an error:
uninitialized constant Knock::Authenticable
Everything works when starting with Rails 5.2.3 and and then updating to Rails 6.
There are also errors when using the generators:
rails generate knock:install
_[WARNING] Could not load generator "generators/knock/install_generator". Error: expected file /Users/thomas/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/knock-2.1.1/lib/generators/knock/install_generator.rb to define constant InstallGenerator, but didn't._
rails generate knock:token_controller user
_[WARNING] Could not load generator "generators/knock/token_controller_generator". Error: expected file /Users/thomas/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/knock-2.1.1/lib/generators/knock/token_controller_generator.rb to define constant TokenControllerGenerator, but didn't._
class ApplicationController < ActionController::API
include Knock::Authenticable
before_action :authenticate_user
end
_NameError (uninitialized constant Knock::Authenticable)_
@thoechtl I think it'll be fixed when 2.2 (#248) gets released. I'll close this for instance, and if the problem persists after it, we can reopen this issue.
Thank you
when will the new version(2.2) come out? because with my new project I can't use this gem for this
The last commit 9214cd0 from March 16 should work with Rails 6. If you can't wait specify the commit in your gemfile and update later to version 2.2:
gem 'knock', git: 'https://github.com/nsarno/knock', branch: 'master', ref: '9214cd027422df8dc31eb67c60032fbbf8fc100b'
The last commit 9214cd0 from March 16 should work with Rails 6. If you can't wait specify the commit in your gemfile and update later to version 2.2:
gem 'knock', git: 'https://github.com/nsarno/knock', branch: 'master', ref: '9214cd027422df8dc31eb67c60032fbbf8fc100b'
THANKS!!!!!
@sbrocos , After referencing the git branch and ref as you suggested, I get the error 'Could not find generator 'knock:install'.' I added the line 'config.load_defaults 6.0 and config.autoloader = :classic' to my application.rb and still no change in output.
@Tripple-A Did you ever figure out how to get things working? I'm stuck around this point as well. Strangely, the current readme for knock doesn't even mention generators, but all blog posts I'm finding _do_ mention generators. Maybe they are no longer used?
It's really unclear how my token controller is meant to look.
I didn't, it appears it isn't compatible with Rails 6.0 yet. I eventually
used another gem for authentication.
On Wed, Jun 17, 2020, 19:36 David Gay notifications@github.com wrote:
@Tripple-A https://github.com/Tripple-A Did you ever figure out how to
get things working? I'm stuck around this point as well. Strangely, the
current readme for knock doesn't even mention generators, but all blog
posts I'm finding do mention generators. Maybe they are no longer used?It's really unclear how my token controller is meant to look.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/nsarno/knock/issues/250#issuecomment-645549098, or
unsubscribe
https://github.com/notifications/unsubscribe-auth/AMRHFUDO3A2WTLJQOPLNF53RXEELDANCNFSM4J3HGRJA
.
For any future travelers, I figured it out. I've got knock working in my Rails 6 API. I wrote up the details here: https://davidgay.org/programming/jwt-auth-rails-6-knock/
It's coming up on a year since this was opened, will version 2.2 ever be released?
Hello from the future!
Still no 2.2, huh?
Most helpful comment
The last commit 9214cd0 from March 16 should work with Rails 6. If you can't wait specify the commit in your gemfile and update later to version 2.2:
gem 'knock', git: 'https://github.com/nsarno/knock', branch: 'master', ref: '9214cd027422df8dc31eb67c60032fbbf8fc100b'