0

我有一个在本地运行但在部署到 heroku 后不运行的应用程序。在 Heroku 上,应用程序默认为“Welcome Aboard”页面。该文件已在本地删除。

我已经尝试解决这个问题几个小时,并尝试了其他 Stackoverflow 答案中提出的建议,其中最常见的是:

heroku run rake db:migrate
heroku restart

无济于事。

这个问题似乎与我之前执行的数据库迁移有关。日志显示:

2013-02-10T06:58:31+00:00 app[web.1]: Processing by CorporationsController#new as HTML
2013-02-10T06:58:31+00:00 app[web.1]: Started GET "/corporations/new" for 64.236.139.254 at 2013-02-10 06:58:31 +0000
2013-02-10T06:58:31+00:00 app[web.1]:     28:     <%= f.text_field :incorporation_date %>
2013-02-10T06:58:31+00:00 app[web.1]:   Rendered corporations/new.html.erb within layouts/application (51.7ms)
2013-02-10T06:58:31+00:00 app[web.1]:   Rendered corporations/_form.html.erb (36.4ms)
2013-02-10T06:58:31+00:00 app[web.1]: Completed 500 Internal Server Error in 60ms
2013-02-10T06:58:31+00:00 app[web.1]:     26:   <div class="field">
2013-02-10T06:58:31+00:00 app[web.1]:     27:     <%= f.label :incorporation_date %><br />
2013-02-10T06:58:31+00:00 app[web.1]: 
2013-02-10T06:58:31+00:00 app[web.1]: ActionView::Template::Error (undefined method `incorporation_date' for #<Corporation:0x00000001e8c5c8>):
2013-02-10T06:58:31+00:00 app[web.1]:   app/views/corporations/_form.html.erb:28:in `block in _app_views_corporations__form_html_erb__2627361166614576795_14624240'
2013-02-10T06:58:31+00:00 app[web.1]:     29:   </div>
2013-02-10T06:58:31+00:00 app[web.1]:   app/views/corporations/new.html.erb:3:in `_app_views_corporations_new_html_erb___3891731594578946395_15501200'
2013-02-10T06:58:31+00:00 app[web.1]:     30:   <div class="actions">
2013-02-10T06:58:31+00:00 app[web.1]:     25:   </div>
2013-02-10T06:58:31+00:00 app[web.1]: 
2013-02-10T06:58:31+00:00 app[web.1]:   app/views/corporations/_form.html.erb:1:in `_app_views_corporations__form_html_erb__2627361166614576795_14624240'
2013-02-10T06:58:31+00:00 app[web.1]:     31:     <%= f.submit %>
2013-02-10T06:58:31+00:00 app[web.1]:   app/controllers/corporations_controller.rb:34:in `new'
2013-02-10T06:58:31+00:00 app[web.1]: 

我有三个如下所示的迁移文件:

20130209192118_create_corporations.rb

class CreateCorporations < ActiveRecord::Migration
  def change
    create_table :corporations do |t|
      t.string :name
      t.string :shares
      t.string :par_value
      t.string :incorporation_date
      t.timestamps
    end
  end
end

20130209231940_add_filing_date_to_corporations.rb

class AddFilingDateToCorporations < ActiveRecord::Migration
  def change
    add_column :corporations, :filing_date, :date
  end
end

20130209232108_remove_incorporation_date_from_corporations

class RemoveIncorporationDateFromCorporations < ActiveRecord::Migration
  def up
    remove_column :corporations, :incorporation_date
  end

  def down
    add_column :corporations, :incorporation_date, :string
  end
end

真的很感激任何想法......

4

1 回答 1

3

在您上次迁移中,您incorporation_date从表中删除列,但在您corporations/_form.html.erb调用f.label :incorporation_date. 奇怪的是它在本地工作;可能是您没有运行最新的迁移或手动编辑表。

于 2013-02-10T07:27:52.903 回答