chaps-io / access-granted

Multi-role and whitelist based authorization gem for Rails (and not only Rails!)
MIT License
774 stars 41 forks source link

Ability usage with grape #14

Closed badlamer closed 8 years ago

badlamer commented 8 years ago

Similar to https://github.com/CanCanCommunity/cancancan/blob/develop/lib/cancan/controller_additions.rb#L297

pokonski commented 8 years ago

hi @badlamer. Thanks for the PR! Does it crash for you when including in Grape projects without this change?

That module is only included in Rails projects like this:

https://github.com/chaps-io/access-granted/blob/master/lib/access-granted.rb#L11-L21

So it shouldn't be executed in non-Rails projects.

badlamer commented 8 years ago

This works with Grape and ApplicationCable::Channel. Without changes grape NoMethodError (undefined method `helper_method' for #) when execute

class API < Grape::API
  helpers AccessGranted::Rails::ControllerMethods
end
pokonski commented 8 years ago

Cool, let's merge it then! Time for me to add those hooks to support Grape out of the box :)

pokonski commented 8 years ago

I just released 1.0.2 version with your fix, thanks for the report and keep the bug fixes coming!