当我转到新的帖子页面时,它会向我显示此错误:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
所以我检查了日志:
$ heroku logs
2016-06-24T14:39:23.117032+00:00 app[web.1]:
2016-06-24T14:39:23.114700+00:00 app[web.1]: User Load (0.7ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:39:23.117050+00:00 app[web.1]:
2016-06-24T14:39:22.859142+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=61e39667-302f-42c7-b54b-c111a6e7
4d71 fwd="51.36.189.186" dyno=web.1 connect=1ms service=24ms status=500 bytes=17
54
2016-06-24T14:39:23.120773+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=d2f95813-1b76-409d-a9f7-a78ad625
be69 fwd="51.36.189.186" dyno=web.1 connect=1ms service=14ms status=500 bytes=17
54
2016-06-24T14:40:33.236242+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by the-cuboid@hotmail.com
2016-06-24T14:40:37.069491+00:00 heroku[run.9307]: Awaiting client
2016-06-24T14:40:37.096467+00:00 heroku[run.9307]: Starting process with command
`bundle exec rake db:migrate`
2016-06-24T14:40:37.160101+00:00 heroku[run.9307]: State changed from starting t
o up
2016-06-24T14:40:41.822801+00:00 heroku[run.9307]: Process exited with status 0
2016-06-24T14:40:41.839281+00:00 heroku[run.9307]: State changed from up to comp
lete
2016-06-24T14:41:07.887878+00:00 app[web.1]: Started GET "/blog_posts/new" for 5
1.36.189.186 at 2016-06-24 14:41:07 +0000
2016-06-24T14:41:07.928317+00:00 app[web.1]:
2016-06-24T14:41:07.928328+00:00 app[web.1]: ActiveRecord::UnknownAttributeError
(unknown attribute 'user_id' for BlogPost.):
2016-06-24T14:41:07.928329+00:00 app[web.1]: app/controllers/blog_posts_contro
ller.rb:19:in `new'
2016-06-24T14:41:07.928330+00:00 app[web.1]:
2016-06-24T14:41:07.893808+00:00 app[web.1]: Processing by BlogPostsController#n
ew as HTML
2016-06-24T14:41:07.900576+00:00 app[web.1]: User Load (1.1ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:41:07.923473+00:00 app[web.1]: Completed 500 Internal Server Error
in 30ms (ActiveRecord: 1.1ms)
2016-06-24T14:41:07.928331+00:00 app[web.1]:
2016-06-24T14:41:07.934843+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=8af2d65a-262d-4f25-a988-e4815c60
7bd6 fwd="51.36.189.186" dyno=web.1 connect=1ms service=50ms status=500 bytes=17
54
2016-06-24T14:41:08.198891+00:00 heroku[router]: at=info method=GET path="/favic
on.ico" host=hisaan.herokuapp.com request_id=f99fd00e-cef4-47ad-ae05-07f1590d9d9
2 fwd="51.36.189.186" dyno=web.1 connect=1ms service=13ms status=200 bytes=228
2016-06-24T14:41:57.122890+00:00 app[web.1]: Started GET "/" for 51.36.189.186 a
t 2016-06-24 14:41:57 +0000
2016-06-24T14:41:57.134586+00:00 app[web.1]: User Load (0.7ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:41:57.166703+00:00 app[web.1]: Completed 200 OK in 41ms (Views: 39
.7ms | ActiveRecord: 0.7ms)
2016-06-24T14:41:57.140708+00:00 app[web.1]: Rendered pages/_header2.html.erb
(5.8ms)
2016-06-24T14:41:57.125454+00:00 app[web.1]: Processing by PagesController#home
as HTML
2016-06-24T14:41:57.164893+00:00 app[web.1]: Rendered pages/home.html.erb with
in layouts/application (37.6ms)
2016-06-24T14:41:57.416859+00:00 app[web.1]: Started GET "/assets/1.jpg" for 51.
36.189.186 at 2016-06-24 14:41:57 +0000
2016-06-24T14:41:57.637418+00:00 app[web.1]: Started GET "/assets/com.jpg" for 5
1.36.189.186 at 2016-06-24 14:41:57 +0000
2016-06-24T14:41:57.992607+00:00 app[web.1]: Processing by PagesController#home
as HTML
2016-06-24T14:41:57.995937+00:00 app[web.1]: User Load (0.7ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:41:57.997175+00:00 app[web.1]: Rendered pages/_header2.html.erb
(3.2ms)
2016-06-24T14:41:58.006466+00:00 app[web.1]: Completed 200 OK in 14ms (Views: 12
.2ms | ActiveRecord: 0.7ms)
2016-06-24T14:41:57.989773+00:00 app[web.1]: Started GET "/" for 51.36.189.186 a
t 2016-06-24 14:41:57 +0000
2016-06-24T14:41:58.005343+00:00 app[web.1]: Rendered pages/home.html.erb with
in layouts/application (11.5ms)
2016-06-24T14:41:58.784241+00:00 app[web.1]: Started GET "/assets/1.jpg" for 51.
36.189.186 at 2016-06-24 14:41:58 +0000
2016-06-24T14:41:56.133604+00:00 heroku[router]: at=info method=GET path="/favic
on.ico" host=hisaan.herokuapp.com request_id=974bc304-0647-4a0b-af83-edb058345d3
2 fwd="51.36.189.186" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2016-06-24T14:41:59.397828+00:00 app[web.1]: Started GET "/assets/com.jpg" for 5
1.36.189.186 at 2016-06-24 14:41:59 +0000
2016-06-24T14:41:57.170670+00:00 heroku[router]: at=info method=GET path="/" hos
t=hisaan.herokuapp.com request_id=3f472261-f90b-4c03-8461-df3b0aa8e626 fwd="51.3
6.189.186" dyno=web.1 connect=1ms service=50ms status=200 bytes=5382
2016-06-24T14:41:57.646756+00:00 heroku[router]: at=info method=GET path="/asset
s/com.jpg" host=hisaan.herokuapp.com request_id=77ccccfd-dd98-4162-9fe8-69cab15b
323c fwd="51.36.189.186" dyno=web.1 connect=1ms service=16ms status=304 bytes=34
3
2016-06-24T14:41:57.422824+00:00 heroku[router]: at=info method=GET path="/asset
s/1.jpg" host=hisaan.herokuapp.com request_id=5cdb1968-2f2d-4ec1-b599-47a4d1be85
9b fwd="51.36.189.186" dyno=web.1 connect=1ms service=11ms status=304 bytes=343
2016-06-24T14:42:00.665895+00:00 app[web.1]: Processing by BlogPostsController#i
ndex as HTML
2016-06-24T14:42:00.673998+00:00 app[web.1]: User Load (0.7ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:42:00.676600+00:00 app[web.1]: Rendered blog_posts/index.html.er
b within layouts/application (8.6ms)
2016-06-24T14:42:00.675930+00:00 app[web.1]: BlogPost Load (1.0ms) SELECT "bl
og_posts".* FROM "blog_posts"
2016-06-24T14:42:00.678298+00:00 app[web.1]: Rendered layouts/_header.html.erb
(0.7ms)
2016-06-24T14:42:00.663850+00:00 app[web.1]: Started GET "/blog_posts" for 51.36
.189.186 at 2016-06-24 14:42:00 +0000
2016-06-24T14:42:00.678619+00:00 app[web.1]: Completed 200 OK in 13ms (Views: 9.
8ms | ActiveRecord: 1.6ms)
2016-06-24T14:41:58.011615+00:00 heroku[router]: at=info method=GET path="/" hos
t=hisaan.herokuapp.com request_id=32177ecc-4b74-4b43-b58d-e41af06b3982 fwd="51.3
6.189.186" dyno=web.1 connect=1ms service=25ms status=200 bytes=5382
2016-06-24T14:41:59.637792+00:00 heroku[router]: at=info method=GET path="/asset
s/BME1-8665c4d59a4c5496380d5b5e028f7b88bb2abda9ee6b71839a6b5f253b9c3784.jpg" hos
t=hisaan.herokuapp.com request_id=6e2cf143-2478-4449-aa23-47dc9b0e3a2d fwd="51.3
6.189.186" dyno=web.1 connect=0ms service=4ms status=304 bytes=133
2016-06-24T14:41:58.268652+00:00 heroku[router]: at=info method=GET path="/asset
s/application-25535718b674acd46cb1bbdbfcc682f19a8bab87f1ef54ae3f4b7a5fcc7f2bac.c
ss" host=hisaan.herokuapp.com request_id=5282b136-bed9-4c33-b8b1-798cfefd048e fw
d="51.36.189.186" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2016-06-24T14:41:58.481250+00:00 heroku[router]: at=info method=GET path="/asset
s/application-7a1792b27fd8e809255833888935d77745f506c1bb953bc302a2fbd0eae460ac.j
s" host=hisaan.herokuapp.com request_id=18e97d75-2957-47d3-8fb0-d71a56da21d7 fwd
="51.36.189.186" dyno=web.1 connect=1ms service=6ms status=304 bytes=133
2016-06-24T14:41:58.792403+00:00 heroku[router]: at=info method=GET path="/asset
s/1.jpg" host=hisaan.herokuapp.com request_id=1bfac075-6b37-4e7e-aa5b-cefc90be54
ed fwd="51.36.189.186" dyno=web.1 connect=1ms service=11ms status=304 bytes=343
2016-06-24T14:42:01.956878+00:00 app[web.1]: Completed 500 Internal Server Error
in 17ms (ActiveRecord: 0.8ms)
2016-06-24T14:42:01.958696+00:00 app[web.1]:
2016-06-24T14:42:01.958706+00:00 app[web.1]:
2016-06-24T14:42:01.942967+00:00 app[web.1]: User Load (0.8ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:42:01.937615+00:00 app[web.1]: Started GET "/blog_posts/new" for 5
1.36.189.186 at 2016-06-24 14:42:01 +0000
2016-06-24T14:41:59.414484+00:00 heroku[router]: at=info method=GET path="/image
s/science.png" host=hisaan.herokuapp.com request_id=277151f1-b52b-449f-9c78-7872
54e85992 fwd="51.36.189.186" dyno=web.1 connect=1ms service=29ms status=200 byte
s=183524
2016-06-24T14:42:01.958706+00:00 app[web.1]: app/controllers/blog_posts_contro
ller.rb:19:in `new'
2016-06-24T14:42:02.180930+00:00 app[web.1]: Started GET "/blog_posts/new" for 5
1.36.189.186 at 2016-06-24 14:42:02 +0000
2016-06-24T14:42:02.183479+00:00 app[web.1]: Processing by BlogPostsController#n
ew as HTML
2016-06-24T14:42:01.958707+00:00 app[web.1]:
2016-06-24T14:42:01.958705+00:00 app[web.1]: ActiveRecord::UnknownAttributeError
(unknown attribute 'user_id' for BlogPost.):
2016-06-24T14:42:01.940083+00:00 app[web.1]: Processing by BlogPostsController#n
ew as HTML
2016-06-24T14:42:02.185989+00:00 app[web.1]: User Load (0.7ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:42:00.717492+00:00 heroku[router]: at=info method=GET path="/blog_
posts" host=hisaan.herokuapp.com request_id=d03e05e6-6bfb-42ba-a831-1bed9e2f982b
fwd="51.36.189.186" dyno=web.1 connect=1ms service=21ms status=200 bytes=2779
2016-06-24T14:42:02.193743+00:00 app[web.1]:
2016-06-24T14:42:02.193752+00:00 app[web.1]: ActiveRecord::UnknownAttributeError
(unknown attribute 'user_id' for BlogPost.):
2016-06-24T14:42:02.193753+00:00 app[web.1]: app/controllers/blog_posts_contro
ller.rb:19:in `new'
2016-06-24T14:42:02.193753+00:00 app[web.1]:
2016-06-24T14:42:02.192075+00:00 app[web.1]: Completed 500 Internal Server Error
in 8ms (ActiveRecord: 0.7ms)
2016-06-24T14:42:02.193754+00:00 app[web.1]:
2016-06-24T14:41:59.418876+00:00 heroku[router]: at=info method=GET path="/image
s/comp.gif" host=hisaan.herokuapp.com request_id=b047be70-d8a4-4a50-8322-c6b91b7
31e17 fwd="51.36.189.186" dyno=web.1 connect=1ms service=35ms status=200 bytes=4
33197
2016-06-24T14:41:59.415815+00:00 heroku[router]: at=info method=GET path="/asset
s/com.jpg" host=hisaan.herokuapp.com request_id=c4830791-cc2a-45e2-b321-7c94f2d2
8185 fwd="51.36.189.186" dyno=web.1 connect=0ms service=18ms status=304 bytes=34
3
2016-06-24T14:42:01.961525+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=5d3da25b-83bf-46b2-8ac7-ab344d20
8949 fwd="51.36.189.186" dyno=web.1 connect=1ms service=28ms status=500 bytes=17
54
2016-06-24T14:42:02.196982+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=c6841d54-c1b8-4457-bbe0-85f785f8
747d fwd="51.36.189.186" dyno=web.1 connect=1ms service=19ms status=500 bytes=17
54
2016-06-24T14:42:18.083201+00:00 heroku[run.8790]: Awaiting client
2016-06-24T14:42:18.100539+00:00 heroku[run.8790]: Starting process with command
`bundle exec rake db:migrate`
2016-06-24T14:42:18.395002+00:00 heroku[run.8790]: State changed from starting t
o up
2016-06-24T14:42:14.705992+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by the-cuboid@hotmail.com
2016-06-24T14:42:22.103750+00:00 heroku[run.8790]: State changed from up to comp
lete
2016-06-24T14:42:22.100884+00:00 heroku[run.8790]: Process exited with status 0
2016-06-24T14:42:39.825222+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by the-cuboid@hotmail.com
2016-06-24T14:42:44.488427+00:00 heroku[run.2160]: Awaiting client
2016-06-24T14:42:44.482103+00:00 heroku[run.2160]: State changed from starting t
o up
2016-06-24T14:42:44.543967+00:00 heroku[run.2160]: Starting process with command
`bundle exec rake db:migrate`
2016-06-24T14:42:50.589106+00:00 heroku[run.2160]: Process exited with status 0
2016-06-24T14:42:50.594510+00:00 heroku[run.2160]: State changed from up to comp
lete
2016-06-24T14:43:00.647899+00:00 app[web.1]: ActiveRecord::UnknownAttributeError
(unknown attribute 'user_id' for BlogPost.):
2016-06-24T14:43:00.630141+00:00 app[web.1]: Started GET "/blog_posts/new" for 5
1.36.189.186 at 2016-06-24 14:43:00 +0000
2016-06-24T14:43:00.633319+00:00 app[web.1]: Processing by BlogPostsController#n
ew as HTML
2016-06-24T14:43:00.647892+00:00 app[web.1]:
2016-06-24T14:43:00.647901+00:00 app[web.1]:
2016-06-24T14:43:00.644974+00:00 app[web.1]: Completed 500 Internal Server Error
in 10ms (ActiveRecord: 0.8ms)
2016-06-24T14:43:00.647900+00:00 app[web.1]: app/controllers/blog_posts_contro
ller.rb:19:in `new'
2016-06-24T14:43:00.647901+00:00 app[web.1]:
2016-06-24T14:43:00.639287+00:00 app[web.1]: User Load (0.8ms) SELECT "users
".* FROM "users" WHERE "users"."id" = $1 ORDER BY "users"."id" ASC LIMIT 1 [["
id", 1]]
2016-06-24T14:43:00.650882+00:00 heroku[router]: at=info method=GET path="/blog_
posts/new" host=hisaan.herokuapp.com request_id=64efe2cc-d6f6-482a-9a81-68f20144
9dc8 fwd="51.36.189.186" dyno=web.1 connect=1ms service=27ms status=500 bytes=17
54
2016-06-24T14:43:00.904542+00:00 heroku[router]: at=info method=GET path="/favic
on.ico" host=hisaan.herokuapp.com request_id=54f42ec6-3da5-44e3-93e7-db5b7aeedf2
8 fwd="51.36.189.186" dyno=web.1 connect=1ms service=23ms status=200 bytes=228
之后我再次运行rake db:migrate:
$ heroku run rake db:migrate
Running rake db:migrate on hisaan... up, run.2160
/app/vendor/bundle/ruby/2.2.0/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.
rb:2: warning: already initialized constant Bootstrap::VERSION
/app/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/versi
on.rb:2: warning: previous definition of VERSION was here
/app/vendor/bundle/ruby/2.2.0/gems/bootstrap-4.0.0.alpha3/lib/bootstrap/version.
rb:3: warning: already initialized constant Bootstrap::BOOTSTRAP_SHA
/app/vendor/bundle/ruby/2.2.0/gems/bootstrap-sass-3.3.6/lib/bootstrap-sass/versi
on.rb:3: warning: previous definition of BOOTSTRAP_SHA was here
DEPRECATION WARNING: The configuration option `config.serve_static_assets` has b
een renamed to `config.serve_static_files` to clarify its role (it merely enable
s serving everything in the `public` folder and is unrelated to the asset pipeli
ne). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrat
e your configuration files accordingly. (called from <class:Application> at /app
/config/application.rb:26)
ActiveRecord::SchemaMigration Load (0.8ms) SELECT "schema_migrations".* FROM
"schema_migrations"
我无法想象在运行rails s的localhost上发生了什么。甚至可以在localhost上发布新帖子。
答案 0 :(得分:1)
我认为这是一条相关的错误消息:
2016-06-24T14:41:07.928328+00:00 app[web.1]: ActiveRecord::UnknownAttributeError
(unknown attribute 'user_id' for BlogPost.):
2016-06-24T14:41:07.928329+00:00 app[web.1]: app/controllers/blog_posts_controller.rb:19:in `new'
user_id
中BlogPost
模型的属性BlogPostsController.rb
未知。
答案 1 :(得分:0)
在生产模式下运行时,将缓存数据库模式。因此,每当进行迁移时,都需要使用heroku restart
命令跟进迁移,以加载更新的架构。