GithubHelp home page GithubHelp logo

Cancan usage? about ckeditor HOT 5 CLOSED

sonnymai avatar sonnymai commented on August 28, 2024
Cancan usage?

from ckeditor.

Comments (5)

galetahub avatar galetahub commented on August 28, 2024 1

Added support for cancan integration in this commit d336964

from ckeditor.

galetahub avatar galetahub commented on August 28, 2024

Try this:

can [:index], Ckeditor::Picture if user.role? :user

from ckeditor.

sonnymai avatar sonnymai commented on August 28, 2024

Thanks for the suggestion. I had tried that before and unfortunately that doesn't work. I just get CanCan::AccessDenied when using that.

heres some lines from the stacktrace:

activesupport (3.1.0) lib/active_support/dependencies.rb:490:in `load_missing_constant'
activesupport (3.1.0) lib/active_support/dependencies.rb:181:in `block in const_missing'
activesupport (3.1.0) lib/active_support/dependencies.rb:179:in `each'
activesupport (3.1.0) lib/active_support/dependencies.rb:179:in `const_missing'
activesupport (3.1.0) lib/active_support/dependencies.rb:501:in `load_missing_constant'
activesupport (3.1.0) lib/active_support/dependencies.rb:181:in `block in const_missing'
activesupport (3.1.0) lib/active_support/dependencies.rb:179:in `each'
activesupport (3.1.0) lib/active_support/dependencies.rb:179:in `const_missing'
app/models/ability.rb:99:in `initialize'
cancan (1.6.5) lib/cancan/controller_additions.rb:349:in `new'
cancan (1.6.5) lib/cancan/controller_additions.rb:349:in `current_ability'
cancan (1.6.5) lib/cancan/controller_additions.rb:330:in `authorize!'
app/controllers/application_controller.rb:17:in `ckeditor_authenticate'
activesupport (3.1.0) lib/active_support/callbacks.rb:430:in `_run__2103710711640583003__process_action__688618921792957714__callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:386:in `_run_process_action_callbacks'

from ckeditor.

adamtao avatar adamtao commented on August 28, 2024

I had the same issue. I figured out that the @asset in the callback is Nil at some point. (Perhaps it creates a dummy asset as a placeholder for the upload link--just guessing.) Anyway, if you just skip the authorize! method if the @asset is Nil, then it works:

  protected
    # Cancan example
    def ckeditor_authenticate
      if @asset
        authorize! action_name, @asset
      end
    end

Also, be sure your ability.rb file uses the suggestion from galetahub above:

can [:index], Ckeditor::Picture if user.role? :user

or

can [:index], Ckeditor::Asset if user.role? :user

from ckeditor.

barmstrong avatar barmstrong commented on August 28, 2024

I ran into this error also.

For me what fixed it was removing #{Rails.root}/app/models/ckeditor from config.autoload_paths in application.rb

from ckeditor.

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.