Arrays frozen in Rails 3.2.4

℡╲_俬逩灬. 提交于 2020-01-01 17:06:16

问题


I recently updated a rails app from 3.0.4 to 3.2.4 and I have a strange problem. It seems every array in my app has become frozen. For example if an array gets a set of articles from the database, that array will be instantiated at the first call of the method and will not change. If an article in the array is deleted in the database, it will still refer to it in the array. It only changes if I restart the server. However, when I call array.frozen? it returns false. And when I deploy to heroku I get this error:

!! Unexpected error while processing request: can't modify frozen array

Any suggestions on what might be causing this? I updated another app and didn't run into this problem.


回答1:


Allright I got it working. I ran heroku run script/rails console and it gave me a new error that I hadn't seen yet. Turns out there was a random line of code in my environments/production.rb file that must've been copy and pasted accidentally or something. After removing it, it cleared up the frozen array problem. After some unrelated gem issues, I was able to get my site back online. So my advice is check your production.rb file and run the heroku console.



来源:https://stackoverflow.com/questions/10990051/arrays-frozen-in-rails-3-2-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!