Skip to content
This repository has been archived by the owner. It is now read-only.

Starting with Rails 6 | uninitialized constant Knock::Authenticable #250

Closed
thoechtl opened this issue Dec 16, 2019 · 10 comments
Closed

Starting with Rails 6 | uninitialized constant Knock::Authenticable #250

thoechtl opened this issue Dec 16, 2019 · 10 comments

Comments

@thoechtl
Copy link

@thoechtl thoechtl commented Dec 16, 2019

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)

@andrerpbts
Copy link
Collaborator

@andrerpbts andrerpbts commented Dec 16, 2019

@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

@sbrocos
Copy link

@sbrocos sbrocos commented Apr 17, 2020

when will the new version(2.2) come out? because with my new project I can't use this gem for this

@thoechtl
Copy link
Author

@thoechtl thoechtl commented Apr 17, 2020

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'

@sbrocos
Copy link

@sbrocos sbrocos commented Apr 17, 2020

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!!!!!

@Tripple-A
Copy link

@Tripple-A Tripple-A commented May 8, 2020

@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.

@dtgay
Copy link

@dtgay dtgay commented Jun 17, 2020

@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.

@Tripple-A
Copy link

@Tripple-A Tripple-A commented Jun 17, 2020

@dtgay
Copy link

@dtgay dtgay commented Jun 17, 2020

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/

@bmulholland
Copy link

@bmulholland bmulholland commented Oct 16, 2020

It's coming up on a year since this was opened, will version 2.2 ever be released?

@pixelpax
Copy link

@pixelpax pixelpax commented Jan 30, 2021

Hello from the future!

Still no 2.2, huh?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants