code-and-effect / effective_datatables

An effective ActiveRecord to Datatables dsl for Ruby on Rails. Make intelligent tables quickly.
MIT License
133 stars 36 forks source link

uninitialized constant Ability #162

Closed alessio-salati closed 3 years ago

alessio-salati commented 3 years ago

after installing as per guide, when I go to view the view I get the following error: uninitialized constant Ability

which comes from the config file at line: config.authorization_method = Proc.new { |controller, action, resource| authorize!(action, resource) }

why?

matt-riemer commented 3 years ago

Hey!

This authorization_method is the hook so you can tell datatables "this user is permitted to do this action".

The authorize! method is comes from cancancan one of the most popular ruby authorization libraries.

Just replace that call to authorize with true and you'll be set.

Cheers. :)

alessio-salati commented 3 years ago

in reality I still have a similar error if I set the parameter to true and then use the boolean configuration: config.authorization_method = true # Always authorized

even if set to true i get this error:

NameError in Static#report Showing /Users/alessiosalati/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/effective_resources-1.8.27/app/views/effective/resource/_actions_dropleft.html.haml where line #2 raised: uninitialized constant Ability Trace of template inclusion: #<ActionView::Template app/views/static/report.html.erb locals=[]>

test I had already done before opening the post.