Will upgrading gems break old Rails applications?

大城市里の小女人 提交于 2020-03-05 03:25:21

问题


I have bunch of Rails apps running on Rails 1.x. I need to upgrade the gems so the question is, will these old apps still work after I upgrade gems?

Thank you.


回答1:


The only way to be sure is to test, of course; that said, if you want to be sure the application works while you test, I believe that you can run

rake rails:freeze:gems

to copy the currently installed gems to the vendor folder inside your project. If, after testing, your project can use newer versions, run

rake rails:unfreeze

to return to the system installed versions of the gems.




回答2:


It depends. If you're talking about upgrading to the latest gems that comprise Rails then if the applications use features that were long ago deprecated and subsequently removed, then they will break.

The only way to know for sure is to try it. Look out for deprecation warnings in the development log. Hopefully you have good test suites in place.




回答3:


It's just like any other dependency. Look at the version number for each gem:

1.2.3

In this case, 1 is the major version. If this number has changed, then definitely do not upgrade. It will require work to use the new one.

2 is the minor version. You should be safe upgrading if only this number has changed, but be careful. Do a lot of smoke tests.

3 is a bug fix release. You can definitely upgrade if only this has changed. It's unlikely only this one has changed after so long, but if that's the case you're safe.

Unfortunately these are only guidelines, and many open-source projects among others do not follow them very well. So take the advice with a grain of salt.




回答4:


If you are running with rails 1.x and you upgrade the rails gem, your application will break. Rails 2.x is very different.

Concerning other gems, they might break. Read the releases note, usually authors warn about backward compatibility.

If you don't want to upgrade, you could also freeze the gems.



来源:https://stackoverflow.com/questions/2146759/will-upgrading-gems-break-old-rails-applications

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