设计导致Heroku错误

时间:2015-08-15 16:33:16

标签: ruby-on-rails ruby-on-rails-4 heroku

更新通过在routes.rbconfig.sign_out_via = :delete进行一次换行,修复了退出问题。据我所知,这允许用户使用HTTP删除方法注销。我真的不明白的是create new post功能在此更改后的工作原理。如果有人能够解释这一点,我将非常感激。

更新:我应该提到我的生产数据库是最新的,heroku运行rake db:migrate是我在google搜索时遇到的第一个解决方案,但还没有解决我的问题。

此外,我使用AWS S3存储以前工作正常的图像,直到我添加了我的设计功能

相关应用程序托管在我的GitHub here

我的图片分享应用程序在我的开发环境中使用sqlite完美运行。在生产中(在Heroku上)我使用的是postgres。我想这个问题与使用Devise和Postgres有关。

当我尝试在http://imgfall.herokuapp.com/posts/new创建新帖子或在http://imgfall.herokuapp.com/users/sign_out签名后退出时,会出现问题。

注销链接只显示标准的Rails错误页面The page you were looking for doesn't exist.这似乎是路由问题,但我不知道解决方案。我的生产路线似乎与开发相同,所以不应该有问题(对吧?)

我检查了heroku日志,其中显示了与创建新帖子相关的以下错误:

Started GET "/posts/new" for 174.102.98.169 at 2015-08-15 16:19:47 +0000
Completed 500 Internal Server Error in 8ms
Processing by PostsController#new as HTML

ActiveRecord::UnknownAttributeError (unknown attribute: user_id):
  app/controllers/posts_controller.rb:31:in `new'


Processing by PostsController#new as HTML

ActiveRecord::UnknownAttributeError (unknown attribute: user_id):
  app/controllers/posts_controller.rb:31:in `new'


Started GET "/posts/new" for 174.102.98.169 at 2015-08-15 16:19:47 +0000
Completed 500 Internal Server Error in 3ms

以及与注销相关的以下错误:

Started DELETE "/users/sign_out" for 174.102.98.169 at 2015-08-15 16:21:19 +0000

ActionController::RoutingError (No route matches [DELETE] "/users/sign_out"):
  vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:38:in `call_app'
  vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `block in call'
  vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `block in tagged'
  vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:26:in `tagged'
  vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `tagged'
  vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `call'
  vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/methodoverride.rb:21:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/runtime.rb:17:in `call'
  vendor/bundle/ruby/2.0.0/gems/activesupport-4.1.8/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  vendor/bundle/ruby/2.0.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/static.rb:84:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/sendfile.rb:112:in `call'
  vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
  vendor/bundle/ruby/2.0.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/lock.rb:17:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/content_length.rb:14:in `call'
  vendor/bundle/ruby/2.0.0/gems/rack-1.5.5/lib/rack/handler/webrick.rb:60:in `service'
  vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
  vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
  vendor/ruby-2.0.0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'

当我运行Heroku run rake routes时,我得到:

Running `rake routes` attached to terminal... up, run.9186
                  Prefix Verb   URI Pattern                                 Controller#Action
        new_user_session GET    /users/sign_in(.:format)                    devise/sessions#new
            user_session POST   /users/sign_in(.:format)                    devise/sessions#create
    destroy_user_session GET    /users/sign_out(.:format)                   devise/sessions#destroy
           user_password POST   /users/password(.:format)                   devise/passwords#create
       new_user_password GET    /users/password/new(.:format)               devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)              devise/passwords#edit
                         PATCH  /users/password(.:format)                   devise/passwords#update
                         PUT    /users/password(.:format)                   devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)                     registrations#cancel
       user_registration POST   /users(.:format)                            registrations#create
   new_user_registration GET    /users/sign_up(.:format)                    registrations#new
  edit_user_registration GET    /users/edit(.:format)                       registrations#edit
                         PATCH  /users(.:format)                            registrations#update
                         PUT    /users(.:format)                            registrations#update
                         DELETE /users(.:format)                            registrations#destroy
           post_comments GET    /posts/:post_id/comments(.:format)          comments#index
                         POST   /posts/:post_id/comments(.:format)          comments#create
        new_post_comment GET    /posts/:post_id/comments/new(.:format)      comments#new
       edit_post_comment GET    /posts/:post_id/comments/:id/edit(.:format) comments#edit
            post_comment GET    /posts/:post_id/comments/:id(.:format)      comments#show
                         PATCH  /posts/:post_id/comments/:id(.:format)      comments#update
                         PUT    /posts/:post_id/comments/:id(.:format)      comments#update
                         DELETE /posts/:post_id/comments/:id(.:format)      comments#destroy
                   posts GET    /posts(.:format)                            posts#index
                         POST   /posts(.:format)                            posts#create
                new_post GET    /posts/new(.:format)                        posts#new
               edit_post GET    /posts/:id/edit(.:format)                   posts#edit
                    post GET    /posts/:id(.:format)                        posts#show
                         PATCH  /posts/:id(.:format)                        posts#update
                         PUT    /posts/:id(.:format)                        posts#update
                         DELETE /posts/:id(.:format)                        posts#destroy
                    root GET    /                                           posts#index

以下是我的开发环境路线:

                  Prefix Verb   URI Pattern                                 Controller#Action
        new_user_session GET    /users/sign_in(.:format)                    devise/sessions#new
            user_session POST   /users/sign_in(.:format)                    devise/sessions#create
    destroy_user_session GET    /users/sign_out(.:format)                   devise/sessions#destroy
           user_password POST   /users/password(.:format)                   devise/passwords#create
       new_user_password GET    /users/password/new(.:format)               devise/passwords#new
      edit_user_password GET    /users/password/edit(.:format)              devise/passwords#edit
                         PATCH  /users/password(.:format)                   devise/passwords#update
                         PUT    /users/password(.:format)                   devise/passwords#update
cancel_user_registration GET    /users/cancel(.:format)                     registrations#cancel
       user_registration POST   /users(.:format)                            registrations#create
   new_user_registration GET    /users/sign_up(.:format)                    registrations#new
  edit_user_registration GET    /users/edit(.:format)                       registrations#edit
                         PATCH  /users(.:format)                            registrations#update
                         PUT    /users(.:format)                            registrations#update
                         DELETE /users(.:format)                            registrations#destroy
           post_comments GET    /posts/:post_id/comments(.:format)          comments#index
                         POST   /posts/:post_id/comments(.:format)          comments#create
        new_post_comment GET    /posts/:post_id/comments/new(.:format)      comments#new
       edit_post_comment GET    /posts/:post_id/comments/:id/edit(.:format) comments#edit
            post_comment GET    /posts/:post_id/comments/:id(.:format)      comments#show
                         PATCH  /posts/:post_id/comments/:id(.:format)      comments#update
                         PUT    /posts/:post_id/comments/:id(.:format)      comments#update
                         DELETE /posts/:post_id/comments/:id(.:format)      comments#destroy
                   posts GET    /posts(.:format)                            posts#index
                         POST   /posts(.:format)                            posts#create
                new_post GET    /posts/new(.:format)                        posts#new
               edit_post GET    /posts/:id/edit(.:format)                   posts#edit
                    post GET    /posts/:id(.:format)                        posts#show
                         PATCH  /posts/:id(.:format)                        posts#update
                         PUT    /posts/:id(.:format)                        posts#update
                         DELETE /posts/:id(.:format)                        posts#destroy
                    root GET    /                                           posts#index

0 个答案:

没有答案