Is it possible to define capabilities in a separate file and include them in the .rb file inside the initialize method?
the code below returns: try and got: undefined method 'can'
ability.rb
def initialize(user) include MyExtension::Something::CustomAbilities ... end
Library / my_extension / something.rb
module MyExtension::Something module CustomAbilities can :do_it, Project do |project| check_something_here and return true or false... end end end
the ideal solution, if possible, would be to extend the class Ability with Ability.send: include / extend, so without explicitly including it in the initialize method
ruby ruby-on-rails cancan
Artur79
source share