我已经设置了 capistrano 以使用与 railscasts Pro 剧集http://railscasts.com/episodes/335-deploying-to-a-vps?view=asciicast中完全相同的配置/设置进行部署。
所有的部署:检查、状态和冷任务都运行并成功完成(经过一些修补)。但是,该应用程序未运行并显示经典的“出现问题”错误页面。当我检查我的 unicorn.log 时,它显示以下错误:
我曾尝试在包含该模块之前要求该模块以解决线程安全问题,并在 application.rb 中自动加载绝对路径。请注意,这一切都在开发环境中有效。
如何修改我的代码来解决这个 NameError 问题?
独角兽日志
E, [2013-10-16T04:15:00.313177 #12996] ERROR -- : uninitialized constant AnswersController::Teebox (NameError)
/home/andrew/rails/teebox/releases/20131016032538/app/controllers/answers_controller.rb:5:in `<class:AnswersController>'
/home/andrew/rails/teebox/releases/20131016032538/app/controllers/answers_controller.rb:1:in `<top (required)>'
answers_controller.rb
class AnswersController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show]
load_and_authorize_resource
require 'teebox/commentable'
include Teebox::Commentable # Offending line
...
end
lib/teebox/commentable.rb
require 'active_support/concern'
module Teebox::Commentable
extend ActiveSupport::Concern
included do
before_filter :comments
end
def comments
@comment = Comment.new
end
end
应用程序.rb
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/decorators)
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %W(#{config.root}/lib/teebox/commentable.rb)
眼镜:
capistrano 2.15.5
rails 3.2.14
ruby 1.9.3-p488
ubuntu 12.04
如果有人需要更多代码,请大声喊叫。