0

Heroku にプッシュしたばかりのアプリを開こうとすると、以下のエラーが発生します。ローカルではすべて正常に動作します。rake db:reset、pg:reset、db:migrate を使用して削除と再プッシュを試みましたが、すべてのテーブルに複数の名前があります。また、各ステップの後に再起動しました データベースが Heroku ダッシュボードに表示されます。今後のプロジェクトの概念実証としてこれを使用したいと思っていましたが、これで完全に壁にぶつかりました!

ActiveRecord::StatementInvalid (PGError: エラー: リレーション「投稿」が存在しません

ブログのチュートリアルに基づいてアプリを作成しましたが、うまく動作します。その後、他の 2 つのテーブルを (他のチュートリアルに従って) 追加し、Nokogiri を使用するレーキ タスクを設定しましたが、それがどのようにリンクを壊したのかわかりません。投稿テーブルに?

全文はこちら: https://github.com/mwhammond/futurebot

アプリにアクセスした後のログの詳細

2013-05-08T09:55:12.832527+00:00 app[web.1]: Started GET "/" for 155.198.164.33
at 2013-05-08 09:55:12 +0000
2013-05-08T09:55:12.925179+00:00 app[web.1]: Processing by PostsController#index
 as HTML
2013-05-08T09:55:13.026158+00:00 app[web.1]: ):
2013-05-08T09:55:13.024635+00:00 app[web.1]: Completed 500 Internal Server Error
 in 99ms
2013-05-08T09:55:13.026158+00:00 app[web.1]:              ORDER BY a.attnum
2013-05-08T09:55:13.025910+00:00 app[web.1]:
     ^
2013-05-08T09:55:13.025910+00:00 app[web.1]:
2013-05-08T09:55:13.026158+00:00 app[web.1]:
**2013-05-08T09:55:13.025910+00:00 app[web.1]: ActiveRecord::StatementInvalid (PGE
rror: ERROR:  relation "posts" does not exist**
2013-05-08T09:55:13.025910+00:00 app[web.1]:              WHERE a.attrelid = '"p
osts"'::regclass
2013-05-08T09:55:13.025910+00:00 app[web.1]: LINE 5:              WHERE a.attrel
id = '"posts"'::regclass
2013-05-08T09:55:13.026158+00:00 app[web.1]:
2013-05-08T09:55:13.025910+00:00 app[web.1]:                      pg_get_expr(d.
adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
2013-05-08T09:55:13.026158+00:00 app[web.1]:   app/controllers/posts_controller.
rb:5:in `index'
2013-05-08T09:55:13.025910+00:00 app[web.1]:               FROM pg_attribute a L
EFT JOIN pg_attrdef d
2013-05-08T09:55:13.025910+00:00 app[web.1]:                AND a.attnum > 0 AND
 NOT a.attisdropped
2013-05-08T09:55:13.025910+00:00 app[web.1]:                 ON a.attrelid = d.a
drelid AND a.attnum = d.adnum

投稿モデル:

class Post < ActiveRecord::Base
  attr_accessible :content, :contentSummary, :image, :link, :score, :title, :tags_attributes

  has_many :comments
  has_many :tags

  accepts_nested_attributes_for :tags, :allow_destroy => :true,
  :reject_if => proc { |attrs| attrs.all? { |k,v| v.blank?} }

end



posts Controller:

class PostsController < ApplicationController
  # GET /posts
  # GET /posts.json
  def index
    @posts = Post.all

    respond_to do |format|
      format.html # index.html.erb
      format.json { render json: @posts }
    end
  end

  # GET /posts/1
  # GET /posts/1.json
  def show
    @post = Post.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @post }
    end
  end

  # GET /posts/new
  # GET /posts/new.json
  def new
    @post = Post.new

    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @post }
    end
  end

  # GET /posts/1/edit
  def edit
    @post = Post.find(params[:id])
  end

  # POST /posts
  # POST /posts.json
  def create
    @post = Post.new(params[:post])

    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, notice: 'Post was successfully created.' }
        format.json { render json: @post, status: :created, location: @post }
      else
        format.html { render action: "new" }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  # PUT /posts/1
  # PUT /posts/1.json
  def update
    @post = Post.find(params[:id])

    respond_to do |format|
      if @post.update_attributes(params[:post])
        format.html { redirect_to @post, notice: 'Post was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  def upVote
    @post = Post.find(params[:id])
    @post.increment!(:score)
    format.html { redirect_to posts_url }
    format.json { head :no_content }
  end


  # DELETE /posts/1
  # DELETE /posts/1.json
  def destroy
    @post = Post.find(params[:id])
    @post.destroy

    respond_to do |format|
      format.html { redirect_to posts_url }
      format.json { head :no_content }
    end
  end
end

移行

class CreatePosts < ActiveRecord::Migration
  def change
    create_table :posts do |t|
      t.string :title
      t.text :content
      t.text :contentSummary
      t.integer :score
      t.string :image
      t.string :link

      t.timestamps
    end
  end
end

heroku rake:db migrate の結果 (cmd からコピーすると最初の文字が削除されます)

igrating to CreateComments (20130501205150)
=  CreateComments: migrating =================================================
- create_table(:comments)
OTICE:  CREATE TABLE will create implicit sequence "comments_id_seq" for serial
column "comments.id"
OTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "comments_pkey" f
r table "comments"
  -> 0.0765s
- add_index(:comments, :post_id)
  -> 0.0419s
=  CreateComments: migrated (0.1186s) ========================================

別のリセットと移行後の完全なログ

C:\..futurebot>heroku open
Opening warm-eyrie-3091... done

C:\..\code\futurebot>heroku logs
2013-05-08T11:02:50.243561+00:00 heroku[web.1]: State changed from starting to u
p
2013-05-08T11:02:52.475512+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At l
east one process failed to exit within 10 seconds of SIGTERM
2013-05-08T11:02:52.475715+00:00 heroku[web.1]: Stopping remaining processes wit
h SIGKILL
2013-05-08T11:02:54.540425+00:00 heroku[web.1]: Process exited with status 137
2013-05-08T11:03:51.190205+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by m.w.hammond@live.co.uk
2013-05-08T11:03:53.139998+00:00 heroku[run.7922]: Awaiting client
2013-05-08T11:03:53.183567+00:00 heroku[run.7922]: Starting process with command
 `bundle exec rake db:migrate`
2013-05-08T11:03:54.361849+00:00 heroku[run.7922]: State changed from starting t
o up
2013-05-08T11:03:59.655214+00:00 heroku[run.7922]: Process exited with status 0
2013-05-08T11:03:59.664971+00:00 heroku[run.7922]: State changed from up to comp
lete
2013-05-08T11:04:06.910562+00:00 app[web.1]: Started GET "/" for 155.198.164.33
at 2013-05-08 11:04:06 +0000
2013-05-08T11:04:07.142491+00:00 app[web.1]: Processing by PostsController#index
 as HTML
2013-05-08T11:04:07.440192+00:00 app[web.1]:   Rendered posts/index.html.erb wit
hin layouts/application (20.8ms)
2013-05-08T11:04:07.579532+00:00 heroku[router]: at=info method=GET path=/ host=
warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect=1ms servic
e=702ms status=500 bytes=643
2013-05-08T11:04:07.576031+00:00 app[web.1]: Completed 500 Internal Server Error
 in 433ms
2013-05-08T11:04:07.578136+00:00 app[web.1]:   (in /app/app/assets/javascripts/a
pplication.js:15)):
2013-05-08T11:04:07.578136+00:00 app[web.1]:
2013-05-08T11:04:07.578136+00:00 app[web.1]:     155:
2013-05-08T11:04:07.578136+00:00 app[web.1]:     156:
2013-05-08T11:04:07.578136+00:00 app[web.1]:     158: </body>
2013-05-08T11:04:07.578136+00:00 app[web.1]:     159: </html>
2013-05-08T11:04:07.578136+00:00 app[web.1]:   app/views/layouts/application.htm
l.erb:157:in `_app_views_layouts_application_html_erb___482820919685099463_26157
420'
2013-05-08T11:04:07.578463+00:00 app[web.1]:   app/controllers/posts_controller.
rb:7:in `index'
2013-05-08T11:04:07.578136+00:00 app[web.1]:     154:
2013-05-08T11:04:07.578463+00:00 app[web.1]:
2013-05-08T11:04:07.578463+00:00 app[web.1]:
2013-05-08T11:04:07.578136+00:00 app[web.1]:     157: <%= javascript_include_tag
 "application" %>
2013-05-08T11:04:07.578136+00:00 app[web.1]: ActionView::Template::Error (couldn
't find file 'foundation'
2013-05-08T11:04:07.878076+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host=warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect
=1ms service=30ms status=200 bytes=0
2013-05-08T11:05:06.045135+00:00 app[web.1]: Started GET "/" for 155.198.164.33
at 2013-05-08 11:05:06 +0000
2013-05-08T11:05:06.050046+00:00 app[web.1]: Processing by PostsController#index
 as HTML
2013-05-08T11:05:06.054225+00:00 app[web.1]:   Rendered posts/index.html.erb wit
hin layouts/application (0.0ms)
2013-05-08T11:05:06.070776+00:00 app[web.1]:   (in /app/app/assets/javascripts/a
pplication.js:15)):
2013-05-08T11:05:06.070776+00:00 app[web.1]:
2013-05-08T11:05:06.070776+00:00 app[web.1]: ActionView::Template::Error (couldn
't find file 'foundation'
2013-05-08T11:05:06.070776+00:00 app[web.1]:     154:
2013-05-08T11:05:06.070776+00:00 app[web.1]:     155:
2013-05-08T11:05:06.069069+00:00 app[web.1]: Completed 500 Internal Server Error
 in 18ms
2013-05-08T11:05:06.071057+00:00 app[web.1]:
2013-05-08T11:05:06.070776+00:00 app[web.1]:     156:
2013-05-08T11:05:06.070776+00:00 app[web.1]:     158: </body>
2013-05-08T11:05:06.070776+00:00 app[web.1]:     157: <%= javascript_include_tag
 "application" %>
2013-05-08T11:05:06.070776+00:00 app[web.1]:   app/views/layouts/application.htm
l.erb:157:in `_app_views_layouts_application_html_erb___482820919685099463_26157
420'
2013-05-08T11:05:06.071057+00:00 app[web.1]:   app/controllers/posts_controller.
rb:7:in `index'
2013-05-08T11:05:06.071057+00:00 app[web.1]:
2013-05-08T11:05:06.080969+00:00 heroku[router]: at=info method=GET path=/ host=
warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect=1ms servic
e=35ms status=500 bytes=643
2013-05-08T11:05:06.070776+00:00 app[web.1]:     159: </html>
2013-05-08T11:05:06.555724+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host=warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect
=8ms service=6ms status=304 bytes=0
2013-05-08T12:08:30.478683+00:00 heroku[web.1]: Idling
2013-05-08T12:08:34.015063+00:00 heroku[web.1]: Stopping all processes with SIGT
ERM
2013-05-08T12:08:34.927659+00:00 app[web.1]: [2013-05-08 12:08:34] ERROR SignalE
xception: SIGTERM
2013-05-08T12:08:34.927659+00:00 app[web.1]:    /usr/local/lib/ruby/1.9.1/webric
k/server.rb:90:in `select'
2013-05-08T12:08:44.546949+00:00 heroku[web.1]: Error R12 (Exit timeout) -> At l
east one process failed to exit within 10 seconds of SIGTERM
2013-05-08T12:08:44.548790+00:00 heroku[web.1]: Stopping remaining processes wit
h SIGKILL
2013-05-08T12:08:46.665774+00:00 heroku[web.1]: Process exited with status 137
2013-05-08T12:08:46.682414+00:00 heroku[web.1]: State changed from up to down
2013-05-08T12:33:09.786644+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:reset` by m.w.hammond@live.co.uk
2013-05-08T12:33:11.890651+00:00 heroku[run.1452]: Awaiting client
2013-05-08T12:33:11.911563+00:00 heroku[run.1452]: Starting process with command
 `bundle exec rake db:reset`
2013-05-08T12:33:12.849180+00:00 heroku[run.1452]: State changed from starting t
o up
2013-05-08T12:33:18.476989+00:00 heroku[run.1452]: Process exited with status 0
2013-05-08T12:33:18.500279+00:00 heroku[run.1452]: State changed from up to comp
lete
2013-05-08T12:33:28.451763+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by m.w.hammond@live.co.uk
2013-05-08T12:33:30.568900+00:00 heroku[run.3481]: Awaiting client
2013-05-08T12:33:30.6172
87+00:00 heroku[run.3481]: Starting process with command `bundle exec rake db:mi
grate`
2013-05-08T12:33:31.364453+00:00 heroku[run.3481]: State changed from starting t
o up
2013-05-08T12:33:36.079923+00:00 heroku[run.3481]: Process exited with status 0
2013-05-08T12:33:36.091667+00:00 heroku[run.3481]: State changed from up to comp
lete
2013-05-08T12:33:42.007923+00:00 heroku[web.1]: State changed from down to start
ing
2013-05-08T12:33:44.023815+00:00 heroku[web.1]: Starting process with command `b
undle exec rails server -p 23102`
2013-05-08T12:33:46.965808+00:00 app[web.1]: DEPRECATION WARNING: You have Rails
 2.3-style plugins in vendor/plugins! Support for these plugins will be removed
in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to
your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release
notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-h
as-been-released. (called from <top (required)> at /app/config/environment.rb:5)

2013-05-08T12:33:46.966363+00:00 app[web.1]: DEPRECATION WARNING: You have Rails
 2.3-style plugins in vendor/plugins! Support for these plugins will be removed
in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to
your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release
notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-h
as-been-released. (called from <top (required)> at /app/config/environment.rb:5)

2013-05-08T12:33:46.966723+00:00 app[web.1]: DEPRECATION WARNING: You have Rails
 2.3-style plugins in vendor/plugins! Support for these plugins will be removed
in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to
your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release
notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-h
as-been-released. (called from <top (required)> at /app/config/environment.rb:5)

2013-05-08T12:33:49.595740+00:00 app[web.1]: => Booting WEBrick
2013-05-08T12:33:49.595740+00:00 app[web.1]: => Rails 3.2.13 application startin
g in production on http://0.0.0.0:23102
2013-05-08T12:33:49.595740+00:00 app[web.1]: => Ctrl-C to shutdown server
2013-05-08T12:33:49.595740+00:00 app[web.1]: Connecting to database specified by
 DATABASE_URL
2013-05-08T12:33:49.595740+00:00 app[web.1]: => Call with -d to detach
2013-05-08T12:33:49.801861+00:00 app[web.1]: [2013-05-08 12:33:49] INFO  WEBrick
 1.3.1
2013-05-08T12:33:49.801861+00:00 app[web.1]: [2013-05-08 12:33:49] INFO  ruby 1.
9.2 (2011-07-09) [x86_64-linux]
2013-05-08T12:33:49.802294+00:00 app[web.1]: [2013-05-08 12:33:49] INFO  WEBrick
::HTTPServer#start: pid=2 port=23102
2013-05-08T12:33:50.375695+00:00 heroku[web.1]: State changed from starting to u
p
2013-05-08T12:33:51.484090+00:00 app[web.1]: Started GET "/" for 155.198.164.33
at 2013-05-08 12:33:51 +0000
2013-05-08T12:33:51.625244+00:00 app[web.1]: Processing by PostsController#index
 as HTML
2013-05-08T12:33:51.793939+00:00 app[web.1]:   Rendered posts/index.html.erb wit
hin layouts/application (8.0ms)
2013-05-08T12:33:51.879791+00:00 app[web.1]: Completed 500 Internal Server Error
 in 254ms
2013-05-08T12:33:51.881623+00:00 app[web.1]:
2013-05-08T12:33:51.885578+00:00 heroku[router]: at=info method=GET path=/ host=
warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect=2ms servic
e=412ms status=500 bytes=643
2013-05-08T12:33:51.881623+00:00 app[web.1]:     156:
2013-05-08T12:33:51.881623+00:00 app[web.1]:     158: </body>
2013-05-08T12:33:51.881623+00:00 app[web.1]: ActionView::Template::Error (couldn
't find file 'foundation'
2013-05-08T12:33:51.881623+00:00 app[web.1]:   (in /app/app/assets/javascripts/a
pplication.js:15)):
2013-05-08T12:33:51.881623+00:00 app[web.1]:     154:
2013-05-08T12:33:51.881623+00:00 app[web.1]:     155:
2013-05-08T12:33:51.881906+00:00 app[web.1]:   app/controllers/posts_controller.
rb:7:in `index'
2013-05-08T12:33:51.881906+00:00 app[web.1]:
2013-05-08T12:33:51.881623+00:00 app[web.1]:     157: <%= javascript_include_tag
 "application" %>
2013-05-08T12:33:51.881623+00:00 app[web.1]:     159: </html>
2013-05-08T12:33:51.881623+00:00 app[web.1]:   app/views/layouts/application.htm
l.erb:157:in `_app_views_layouts_application_html_erb__3565313392971739647_35930
440'
2013-05-08T12:33:51.881906+00:00 app[web.1]:
2013-05-08T12:33:52.413616+00:00 heroku[router]: at=info method=GET path=/favico
n.ico host=warm-eyrie-3091.herokuapp.com fwd="155.198.164.33" dyno=web.1 connect
=1ms service=7ms status=304 bytes=0
4

1 に答える 1

1

Heroku で postgreSQL を使用しているため、config/database.yml ファイルを次のように変更する必要があります。

production:
  adapter: PostgreSQL
  database: production
  pool: 5
  timeout: 5000

そして再びそれを移行します

 1)heroku run rake db:reset 
 2) heroku run rake db:migrate 
 3)heroku restart 
 4)heroku open

production グループに gem thin を追加します

group :production do
   gem 'thin'
end
于 2013-05-08T10:43:46.163 に答える