【发布时间】:2018-02-18 12:12:17
【问题描述】:
我是设置 VPS 的新手。
今晚早些时候,我使用 Ubuntu、Postgresql、Nginx、Passenger 设置了一个 VPS。
一直很顺利,直到APP崩溃,现在我刷新页面时总是收到Sorry, something went wrong msg。
我已经使用sudo service nginx restart 重新启动了 NginX
我也重启了postgresql。
我也一次又一次地deployed该应用程序,但没有运气。
在production.log
有这样的消息:
NoMethodError (undefined method '+' for nil:NilClass):
app/controllers/application_controller.rb:101:in `each'
app/controllers/application_controller.rb:101:in `reduce'
app/controllers/application_controller.rb:101:in `users_stats'
现在这个错误总是出现。即使在所有重新启动之后。
更新
这是代码,我设法通过在控制器中注释它并再次部署来使其工作。
all_users_truck_use = User.joins(:transports).where(transports: { transport_type: ['Truck / Lorry', nil] } ).pluck(:transport_km).reduce(:+)
@all_users_Truck_co2 = all_users_truck_use.nil? ? 0 : all_users_truck_use * @Truck.to_f
服务器是否存在某种循环? 我在这里真的很绝望,我需要在星期一早上交付这个项目。
提前致谢
【问题讨论】:
-
请特别向我们展示您的
app/controllers/application_controller.rb文件-101周围的代码。提示第 101 行中的代码会引发错误,因为它试图在nil上调用 add (+)。 -
请看我的更新@spickermann
标签: ruby-on-rails ruby postgresql ubuntu nginx