ruby-on-rails - Heroku 错误 : We're sorry, 但出了点问题

标签 ruby-on-rails heroku devise

我已经将一个应用程序部署到 heroku(来自 udemy.com 的“ROR 开发人员类(class)”下的财务跟踪器)。登录按钮工作正常,但是当我点击注册按钮时,它给了我这个错误

We're sorry, but something went wrong.
If you are the application owner check the logs for more information.

我已成功运行 heroku run rake db:migrate。 我使用 devise gem 进行身份验证。 请问有人知道吗??....谢谢

编辑

来自日志:

2016-10-26T17:46:19.965045+00:00 heroku[router]: at=info method=GET   path="/users/sign_up" host=johnuzoma-finance-tracker.herokuapp.com   request_id=9b928dfe-66be-47b5-933b-3d5b6cf3a899 fwd="197.210.25.210"   dyno=web.1 connect=0ms service=19ms status=500 bytes=1754
2016-10-26T17:46:19.950321+00:00 app[web.1]: Started GET "/users/sign_up"  for 197.210.25.210 at 2016-10-26 17:46:19 +0000
2016-10-26T17:46:19.955368+00:00 app[web.1]: Processing by  User::RegistrationsController#new as HTML
2016-10-26T17:46:19.957892+00:00 app[web.1]: Completed 500 Internal  Server Error in 2ms (ActiveRecord: 0.0ms)
2016-10-26T17:46:19.958887+00:00 app[web.1]:
2016-10-26T17:46:19.958889+00:00 app[web.1]: NoMethodError (undefined  method `for' for #<Devise::ParameterSanitizer:0x007f782dff6408>):
2016-10-26T17:46:19.958890+00:00 app[web.1]:    app/controllers/user/registrations_controller.rb:7:in `configure_permitted_parameters'
2016-10-26T17:46:19.958891+00:00 app[web.1]:
2016-10-26T17:46:19.958892+00:00 app[web.1]:
2016-10-26T17:46:20.651597+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=johnuzoma-finance-tracker.herokuapp.com request_id=8d875ac1-de78-47 68-9cd0-a653afd2318b fwd="197.210.25.210"  dyno=web.1 connect=0ms service=6ms status=304 bytes=133

注册 Controller 代码

class User::RegistrationsController < Devise::RegistrationsController
  before_filter :configure_permitted_parameters

  protected

  def configure_permitted_parameters
    devise_parameter_sanitizer.for(:sign_up).push(:first_name,  :last_name)
    devise_parameter_sanitizer.for(:account_update).push(:first_name, :last_name)
  end
end

最佳答案

因此,您应该做的第一件事是转到应用程序的 Heroku 管理面板并查看日志文件。您应该找到一个堆栈跟踪(应该看起来像一个错误,后面跟着一堆方法调用和行号)。另一种选择是远程访问应用服务器,转到计算机上的 Heroku 应用目录并运行(假设您安装了 Heroku CLI)

heroku run bash 

然后导航到您的日志目录并运行

tail -f <replace_with_log_file_name>

(日志文件应该是 production.log 或 develop.log),这将向您显示日志事件的实时流,因此只需重新创建错误并查看会发生什么。

替换这些行

def configure_permitted_parameters
  devise_parameter_sanitizer.for(:sign_up).push(:first_name,  :last_name)
  devise_parameter_sanitizer.for(:account_update).push(:first_name, :last_name)
end

用这些线

def configure_permitted_parameters
  devise_parameter_sanitizer.permit(:sign_up, keys: [:first_name,  :last_name])
  devise_parameter_sanitizer.permit(:account_update, keys: [:first_name, :last_name])
end

发生的事情是您正在使用的 gem devise 更改了其版本中的 API,因此您正在使用的语法不再有效。我假设您在某个时间点进行了捆绑更新或无意中升级了您的 gem

关于ruby-on-rails - Heroku 错误 : We're sorry, 但出了点问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40019544/

相关文章:

ruby-on-rails - Rails Paperclip 多态样式

javascript - CSS 动画在 Rails 应用程序中不起作用

ruby-on-rails - 我们可以得到 Ruby 和 Rails 的性能统计数据吗?我们正在说服企业使用 Rails!

node.js - 简单的 node.js 套接字服务器

ruby-on-rails - Rails Unicorn Web 服务器无法在 Heroku 上启动

ruby-on-rails - Rails 4 Devise/Omniauth 电子邮件存在于数据库错误

ruby-on-rails - 从 lib 文件夹加载文件以将方法添加到 Rails 3 中的〜现有〜类的最佳方法是什么?

ruby-on-rails - 使用 Devise、Omniauth 和 SoundCloud 登录

ruby-on-rails - 设计的 token_authenticable 安全吗?

heroku - Rails 4 + Github + Heroku : Large file storage