오류: 상수 ApplicationController::CanCan이 초기화되지 않았습니다.
9197 단어 cancan
묘사
내가 보석을 써레질해 보았을 때: 설치:$rake gems:설치
(/Users/tscolari/Projetos/skeleton에서)
라크 유산했어!
초기화되지 않은 상수 ApplicationController::CanCan
(-trace가 있는 작업을 실행하여 전체 추적을 보기)
토론 #1
시스템의 나머지 부분은 cancan이 있는 컨트롤러를 포함하여 정상적으로 작동합니다.더 이상 설치할 수 없어요.토론 #2
추적은 무엇을 보여 줍니까?토론 #셋
rake gems: 설치 - 추적(/Users/tscolari/Projetos/skeleton에서)
*gems:install 호출(처음)
*gems:base 호출(처음)
*실행보석: 기지
* 호출 환경(처음)
** 실행 환경
라크 유산했어!
초기화되지 않은 상수 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:in
로딩,무 신 상수 표식'/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: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:in
요구 사항 또는 로드'/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:in
const 실종'/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:in
로드,무 신 상수 표식'/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: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:in
요구 사항 또는 로드'/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:in
const 실종'/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:in
gem_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:in
요구 사항/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:in
요구 사항/사용자/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:in
evaluate_init_rb'/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active\u support/core\u 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:in
evaluate_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:in
플러그인 로드/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:in
플러그인 로드/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:in
프로세스/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:in
run'/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: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/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in
새 상수/opt/local/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.전보
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636: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:in
마다'/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:631:in
용 call chain'호출/opt/local/lib/ruby/1.8/monitor.rb:242:in
execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
용 call chain'호출/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
호출/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636: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:in
마다'/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:631:in
용 call chain'호출/opt/local/lib/ruby/1.8/monitor.rb:242:in
execute'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in
용 call chain'호출/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:607:in
synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
마다'/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:604:in
용 call chain'호출/opt/local/lib/ruby/1.8/monitor.rb:242:in
invoke_prerequisites'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:596:in
용 call chain'호출/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in
synchronize'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in
호출 퀘스트'/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in
invoke'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in
각/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:in
표준이상처리/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:2068:in
실행/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in
top_level'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in
run'/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 cancangem 버전은 cancan(1.0.2)
standard_exception_handling'
/opt/local/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in
입니다. 프로그램 컨트롤러의rescue from 자구 때문에 발생한 것으로 추정됩니다. 이 자구는 gm를 설치하지 않았을 때 터치됩니다.나는 인자를 문자열로 바꾸어야 할 수도 있다.기사 고마워요.토론 #4
안녕, 리안, 나는 응용 프로그램 컨트롤러에'require'cancan'을 추가해서 이 오류를 없앴다.... 첫 번째 답은 죄송합니다. 문제는 플러그인이 초기화되기 전에 프로그램 controler가 필요하다는 것입니다...다음은 제 솔루션입니다.
# 플러그인 보호
cancan=true
개시하다
내부 핵.콘스터
구조하다
cancan=false
끝맺다
하면, 만약, 만약...
칸칸에서 구출 | 예외 |
flash[:error] = "액세스가 거부되었습니다."
root url로 리디렉션
끝맺다
끝맺다
토론 #5
문구는 컨트롤러/모델 파일 이외에 저장하는 것이 좋으나 환경 설정 파일, 초기 값 설정 항목, bundler (사용하면) 내부에 저장하는 것이 좋습니다.어차피 이게 관례야.만약 내가 오류를 정확하게 이해한다면,
토론 #6
부분을require
의 문자열에 넣으면 그것을 복구할 수 있을 것이다.CanCan::AccessDenied
나는 이미 이 두 가지 해결 방안의 도움말과 효과를 테스트했다. 물론 문자열을 가진 해결 방안이 더 깨끗하다:)ApplicationController
헤이,ryanb,Application Controller
토론 #7
talhait07의 문자열에CanCan::AccessDenied 부분을 따옴표토론 #8
만 붙이면 Puma를 다시 시작할 수 있습니다.Reference
이 문제에 관하여(오류: 상수 ApplicationController::CanCan이 초기화되지 않았습니다.), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://github.com/ryanb/cancan/issues/28텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
우수한 개발자 콘텐츠 발견에 전념 (Collection and Share based on the CC Protocol.)