1

我的应用程序在开发环境中正常运行,但是当我尝试运行时出现以下rails server -e production 错误?

/app/controllers/application_controller.rb:6:in `<class:ApplicationController>': uninitialized constant ApplicationController::CanCan (NameError)
from /home/dexter/Desktop item/Triton/app/controllers/application_controller.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/ckeditor-4.0.4/app/controllers/ckeditor/application_controller.rb:1:in `<top (required)>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:439:in `block (2 levels) in eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:438:in `block in eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:436:in `eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/railties.rb:8:in `all'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/engine.rb:434:in `eager_load!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application/finisher.rb:53:in `block in <module:Finisher>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `instance_exec'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:30:in `run'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:55:in `block in run_initializers'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `each'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/initializable.rb:54:in `run_initializers'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/application.rb:136:in `initialize!'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/railtie/configurable.rb:30:in `method_missing'
from /home/dexter/Desktop item/Triton/config/environment.rb:5:in `<top (required)>'
from /home/dexter/Desktop item/Triton/config.ru:3:in `block in <main>'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
from /home/dexter/Desktop item/Triton/config.ru:in `new'
from /home/dexter/Desktop item/Triton/config.ru:in `<main>'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:46:in `app'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
from /var/lib/gems/1.9.1/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands/server.rb:70:in `start'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:55:in `block in <top (required)>'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `tap'
from /var/lib/gems/1.9.1/gems/railties-3.2.12/lib/rails/commands.rb:50:in `<top (required)>'
from script/rails:6:in `require'
from script/rails:6:in `<main>'

我的应用程序控制器:

class ApplicationController < ActionController::Base
  protect_from_forgery
  before_filter :authenticate_user!


  rescue_from CanCan::AccessDenied do |exception|
    flash[:error] = exception.message
    redirect_to root_path
  end

  private
  def stored_location_for(resource_or_scope)
    nil
  end

  def after_sign_in_path_for(resource_or_scope)
    '/dashboard'
  end



end

Gemfile > 刚刚发布了 CanCan 的地方

group :assets do
  gem 'cancan'

end
4

1 回答 1

1

从 Gemfile 中的资产组中删除 cancan。资产组是不用于生产的宝石。因此,当您在生产模式下运行应用程序时,assets 块中的 gem 将被排除在外。

于 2013-08-14T01:47:30.100 回答