I'm getting undefined method 'authorize_actions_for'
in the controller when using rails-api with the Authority gem. Any ideas what I need to include? Here's my code:
Gemfile:
...
gem 'authority', '~> 2.9.0'
gem 'rails-api', '~> 0.1.0'
...
app/authorizers/session_authorizer.rb:
class SessionAuthorizer < ApplicationAuthorizer
def deletable_by?(user)
user.sessions.include?(resource)
end
end
app/controllers/v1/sessions_controller.rb:
class V1::SessionsController < ApplicationController
authorize_actions_for Session
...
end
Include
Authority::Controller
As we discussed on Github,
authorize_actions_for
is defined inAuthority::Controller
.In a normal Rails app, that module gets included into
ActionController::Base
by Authority'srailtie.rb
. Apparently the railtie isn't being required when using rails-api (maybe theRails
constant isn't defined?).You can include the appropriate module yourself, though: