0

在我最近一次部署到 Heroku 期间,我的应用程序停止工作——不过,它在本地运行良好。该应用程序在 Heroku 的 cedar 堆栈上运行。

在 Heroku 上跟踪日志后,我收集了以下错误:

TypeError ([1] is not a symbol):
app/controllers/application_controller.rb:9:in `new_post'

以下是 application_controller.rb 中的代码:

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :new_post
  before_filter :new_channel

  def new_post
    @new_post = Post.new
    @select_channels = current_user.channels.all
  end

  def new_channel
    @new_channel = Channel.new
  end

  def after_sign_in_path_for(resource)
    browse_path
  end

end

下面是频道的模型:

class Channel < ActiveRecord::Base
    attr_accessible :title, :description, :cover_image, :status, :writable, :visibility

    has_one :channel_publication
    has_one :user, :through => :channel_publication

    has_many :channel_subscriptions

    has_many :channel_post_connections

    accepts_nested_attributes_for :channel_publication
    accepts_nested_attributes_for :user

end

我似乎无法弄清楚导致此 TypeError 的原因,以及为什么它仅在部署到 Heroku 时才会发生。任何帮助,将不胜感激!

4

1 回答 1

0

我最终在这里解决了这个问题——这是一个愚蠢的错误。

为了确保这不是数据库的问题,我使用 Heroku 的 fork 命令对应用程序进行了 fork——创建了一个净化/新鲜的环境和一个干净的数据库。

从那里,同样的错误仍然存​​在,但是,日志给了我更多关于它在哪里的细节......结果我正在循环一个在数据库中没有现有条目的对象。

于 2013-09-21T14:04:49.723 回答