2013-05-08 65 views
0

当我尝试打开刚刚推送到heroku的应用程序时,出现以下错误,本地一切正常。我试过删除并重新推送,使用rake db:reset,pg:reset,db:migrate,并且所有表都有复数名称。我也在每一步后重新启动数据库显示在Heroku仪表板中。任何帮助都会得到真正的赞赏,我希望能够用它来作为即将到来的项目的一个概念证明,但是我已经完全用这个来打了一堵墙!Heroku上的Rails:ActiveRecord :: StatementInvalid,重置和迁移不起作用

的ActiveRecord :: StatementInvalid(PGError:ERROR:关系“上岗”不存在

我建立的应用程序基于博客的教程,并能正常工作,从那以后,我增加了其他2个表(以下等?教程),并设置其采用引入nokogiri耙的任务,但我不明白怎么会已经打破了链接到posts表

全是在这里: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耙结果:DB迁移(从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 [email protected] 
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 [email protected] 
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 [email protected] 
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 

回答

1

你正在使用PostgreSQL在Heroku的,所以你必须改变你的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 

在您的生产组中添加宝石

group :production do 
    gem 'thin' 
end 
+0

嗨,感谢您的帮助,我读过那个heroku忽略了database.yml无论如何,所以我没有尝试过,但现在尝试了它,推动并重新启动,但不幸仍然得到同样的问题。 – iammarkhammond 2013-05-08 11:08:00

+0

迁移后,你尝试heroku重新启动 – Shrikant1712 2013-05-08 11:42:25

+0

我刚刚编辑我的帖子看到它 – Shrikant1712 2013-05-08 11:46:51