首先是我的代码:
class ApplicationController < ActionController::Base
protect_from_forgery
rescue_from Cancan::AccessDenied do |exception|
flash[:error] = "Access denied"
redirect_to root_url
end
end
当我运行一个 deny 页面的时候,出现如下错误:
uninitialized constant ApplicationController::Cancan
SO 的这篇文章是这么说的:http://stackoverflow.com/questions/11315608/uninitialized-constant-applicationcontrollercancan-nameerror-in-production
但是我是直接用 rails s 测试运行的,是不是 webrick 也有不加载的问题呢?
bundle 信息: Using rake (10.0.4) Using i18n (0.6.4) Using multi_json (1.7.2) Using activesupport (3.2.11) Using builder (3.0.4) Using activemodel (3.2.11) Using erubis (2.7.0) Using journey (1.0.4) Using rack (1.4.5) Using rack-cache (1.2) Using rack-test (0.6.2) Using hike (1.2.2) Using tilt (1.3.7) Using sprockets (2.2.2) Using actionpack (3.2.11) Using mime-types (1.22) Using polyglot (0.3.3) Using treetop (1.4.12) Using mail (2.4.4) Using actionmailer (3.2.11) Using arel (3.0.2) Using tzinfo (0.3.37) Using activerecord (3.2.11) Using activeresource (3.2.11) Using bcrypt-ruby (3.0.1) Using cancan (1.6.9) Using coffee-script-source (1.6.2) Using execjs (1.4.0) Using coffee-script (2.2.0) Using rack-ssl (1.3.3) Using json (1.7.7) Using rdoc (3.12.2) Using thor (0.18.1) Using railties (3.2.11) Using coffee-rails (3.2.2) Using commonjs (0.2.6) Using orm_adapter (0.4.0) Using warden (1.2.1) Using devise (2.2.3) Using jquery-rails (2.2.1) Using less (2.3.1) Using less-rails (2.3.2) Using libv8 (3.11.8.17) Using mysql2 (0.3.11) Using bundler (1.2.3) Using rails (3.2.11) Using ref (1.0.4) Using sass (3.2.7) Using sass-rails (3.2.6) Using simple_form (2.1.0) Using therubyracer (0.11.4) Using twitter-bootstrap-rails (2.2.6) Using uglifier (2.0.1)