gonzalo-bulnes/simple_token_authentication — pull request #64 by donbobka (2014-05-18 13:57:56+00:00)
Title: Several devise scopes in one controller

I made a nice feature on top of PR #62
PR adds:
- possibility to use several devise scopes in one controller simultaneously
- helper methods for manual mode
- `authenticate_#{entity_underscored}_from_token!` with devise fallback for throwing authentication error
Example: `authenticate_admin_user_from_token`, `authenticate_user_from_token!`
- `authenticate_#{entity_underscored}_from_token` without fallback and error
Example: `authenticate_admin_user_from_token`, `authenticate_admin_user_from_token`

Example of usage:
```ruby
class PostController < ApplicationController
acts_as_token_authentication_handler_for User, only: [:new, :edit, :create, :update]
acts_as_token_authentication_handler_for AdminUser, only: [:destroy, :hide, :publish]

def index
# ... Accessible for unauthenticated users ...
end

def show
# ... Accessible for unauthenticated users ...
end

def new
# ... Only for authenticated users...
end

def edit
# ... Only for authenticated users...
end

def create
# ... Only for authenticated users...
end

def update
# ... Only for authenticated users...
end

def destroy
# ... Only for authenticated admins...
end

def publish
# ... Only for authenticated admins...
end

def hide
# ... Only for authenticated admins...
end
end
```