【问题标题】:Rails TypeError on Heroku, but not on local serverHeroku上的Rails TypeError,但不在本地服务器上
【发布时间】:2013-09-19 21:05:09
【问题描述】:

在我最近一次部署到 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 时才会发生。任何帮助将不胜感激!

【问题讨论】:

标签: ruby-on-rails ruby ruby-on-rails-3 heroku


【解决方案1】:

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

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

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

【讨论】:

    猜你喜欢
    • 2019-10-16
    • 2020-12-25
    • 2021-04-28
    • 1970-01-01
    • 1970-01-01
    • 2019-07-19
    • 2018-12-05
    • 2021-08-25
    • 2016-11-05
    相关资源
    最近更新 更多