Giter VIP home page Giter VIP logo

Comments (10)

mpapis avatar mpapis commented on June 2, 2024 1

Hi Ryan, I got rid of this error by adding " require 'cancan' " on top of application controler

... sorry for the first answer, problem is plugins are requiring application_controler befor initialization is done ... here is my solution:

  #plugin protection
  is_cancan=true
  begin
    Kernel.const_get('CanCan')
  rescue
    is_cancan=false
  end
  if is_cancan
    rescue_from CanCan::AccessDenied do |exception|
      flash[:error] = 'Access denied.'
      redirect_to root_url
    end
  end

from cancan.

tscolari avatar tscolari commented on June 2, 2024

the rest of the system works just fine, including the controllers with cancan. I just cant rake gems:install anymore.

from cancan.

stellard avatar stellard commented on June 2, 2024

what does the trace say?

from cancan.

tscolari avatar tscolari commented on June 2, 2024

rake gems:install --trace
(in /Users/tscolari/Projetos/skeleton)
** Invoke gems:install (first_time)
** Invoke gems:base (first_time)
** Execute gems:base
** Invoke environment (first_time)
** Execute environment
rake aborted!
uninitialized constant ApplicationController::CanCan
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:105:in const_missing' /Users/tscolari/Projetos/skeleton/app/controllers/application_controller.rb:14 /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:inload_without_new_constant_marking'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in load_file' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:379:in load_file' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:259:inrequire_or_load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:425:in load_missing_constant' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:inconst_missing'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in const_missing' /Users/tscolari/Projetos/skeleton/app/controllers/administration_controller.rb:1 /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:inload_without_new_constant_marking'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in load_file' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:379:in load_file' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:259:inrequire_or_load'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:425:in load_missing_constant' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:inconst_missing'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in const_missing' /Users/tscolari/Projetos/skeleton/vendor/plugins/rails-ckeditor/app/controllers/ckeditor_controller.rb:1 /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:ingem_original_require'
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in new_constants_in' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:inrequire'
/Users/tscolari/Projetos/skeleton/vendor/plugins/rails-ckeditor/init.rb:17:in evaluate_init_rb' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:158:inevaluate_init_rb'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/reporting.rb:11:in silence_warnings' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:154:inevaluate_init_rb'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin.rb:48:in load' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:38:inload_plugins'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:in each' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/plugin/loader.rb:37:inload_plugins'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:369:in load_plugins' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:165:inprocess'
/opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:in send' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/initializer.rb:113:inrun'
/Users/tscolari/Projetos/skeleton/config/environment.rb:9
/opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require' /opt/local/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:inrequire'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' /opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:innew_constants_in'
/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:156:in require' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/misc.rake:4 /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/gems.rake:17 /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:incall'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in execute' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:ininvoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in invoke_prerequisites' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:604:in invoke_prerequisites' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:ininvoke_with_call_chain'
/opt/local/lib/ruby/1.8/monitor.rb:242:in synchronize' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:ininvoke_with_call_chain'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in invoke' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:ininvoke_task'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:ineach'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:instandard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in top_level' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:inrun'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in standard_exception_handling' /opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:inrun'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/opt/local/bin/rake:19:in `load'
/opt/local/bin/rake:19

may cancan gem version is cancan (1.0.2)

from cancan.

ryanb avatar ryanb commented on June 2, 2024

I'm guessing this is due to the rescue_from clause in your ApplicationController which is getting triggered when you don't have the gem installed. I should probably change the argument to use a string. Thanks for reporting this.

from cancan.

ryanb avatar ryanb commented on June 2, 2024

It's best to keep require statements outside of controller/model files, but inside environment config files, initializers, or bundler if you use that. That's the convention anyway.

Placing the CanCan::AccessDenied part in a string in ApplicationController should fix it if I understand the error properly.

from cancan.

mpapis avatar mpapis commented on June 2, 2024

I have tested both solutions help and work, of course that one with string is cleaner :)

from cancan.

talhait07 avatar talhait07 commented on June 2, 2024

hey ryanb ,
how to place CanCan::AccessDenied part in a string in ApplicationController

from cancan.

amfischer avatar amfischer commented on June 2, 2024

talhait07 just put quotes around it

from cancan.

yannickboog avatar yannickboog commented on June 2, 2024

You have to restart Puma.

from cancan.

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.