数据库迁移后部署到heroku的问题

时间:2013-02-10 07:18:26

标签: ruby-on-rails heroku

我有一个在本地运行但在部署到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

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

1 个答案:

答案 0 :(得分:3)

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