【问题标题】:uninitialized constant after capistrano delpoy:cold - nginx, unicorncapistrano delpoy:cold 后未初始化的常量 - nginx,独角兽
【发布时间】:2013-10-17 02:31:59
【问题描述】:

我已经设置了 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

如果有人需要更多代码,请大声疾呼。

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 nginx capistrano


    【解决方案1】:

    我有一个命名约定,这在 Mac 上不是问题,但在区分大小写的 Linux 机器上是一个问题。

    我有一个lib/Teebox/commentable.rb 文件夹结构,然后正在调用:

    include Teebox::Commentable

    所以我将其切换为 lib/teebox/commentable.rb(小写 teebox),这解决了错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多