Code Monkey home page Code Monkey logo

Comments (3)

mrluc avatar mrluc commented on September 23, 2024

Dudes.

So, I went and checked this out ... I found out that you're just using @abstract_model.model.arrange to pull data out of the model, which barring magic (always a possibility in railsland) doesn't seem to allow for CanCan to be applying any sort of filtering from Ability.

But if anyone else out there like me just wants to make CanCan work (ie, not just 'allow/disallow nestable', but full parity with eg 'index' action), go ahead and make a local copy of lib/rails_admin_nestable/nestable.rb, and you can just change lines 75-81 of nestable.rb to

model = @abstract_model.model

# use the accessible_by scope with current user if supported
model = model.accessible_by( Ability.new current_user ) if model.respond_to? :accessible_by

if @nestable_conf.tree?
  @tree_nodes = model.arrange(order: @nestable_conf.options[:position_field])
end

if @nestable_conf.list?
  @tree_nodes = model.order(@nestable_conf.options[:position_field])
end

That'll apply Devise filtering to the records you see in nestable.

Offhand I can't see why this would be a bad thing, but I might be missing something since it's been a while since I knew CanCan/Devise/Radmin inside and out.

from rails_admin_nestable.

bradgreens avatar bradgreens commented on September 23, 2024

+1 @mrluc

from rails_admin_nestable.

dalpo avatar dalpo commented on September 23, 2024

Hi @mrluc,
I released a new version which use the rails_admin method list_entries to retrieve records.
list_entries is integrated with the authorization_adapter, generally CanCan, so the issue should be resolved.

Take a look here for the list_entries implementation: https://github.com/sferik/rails_admin/blob/master/app/controllers/rails_admin/main_controller.rb#L32

Could you try the last release to check if it works correctly?

Sorry for my late reply, but I have little free time to work on rails_admin_nestable..

Thanks

from rails_admin_nestable.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.