Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
Add documentation on how to use Knock with namespaced model
  • Loading branch information
nsarno authored Jun 30, 2016
1 parent 044d2a5 commit daab17c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ Note: the `authenticate_user` method uses the `current_user` method. Overwriting

You can do the exact same thing for any entity. E.g. for `Admin`, use `authenticate_admin` and `current_admin` instead.

If you're using a namespaced model, Knock won't be able to infer it automatically from the method name. Instead you can use `authenticate_for` directly like this:

```ruby
class ApplicationController < ActionController::Base
include Knock::Authenticable

private

def authenticate_v1_user
authenticate_for V1::User
end
end
```

```ruby
class SecuredController < ApplicationController
before_action :authenticate_v1_user
end
```

### Customization

#### Via the entity model
Expand Down

0 comments on commit daab17c

Please sign in to comment.