简体   繁体   English

我应该将Ruby 1.9.2用于我的Rails 2.3.10应用程序吗?

[英]Should I use Ruby 1.9.2 for my Rails 2.3.10 app?

I have an existing Rails 2.3.10 app that I'm considering upgrading to Ruby 1.9.2 from 1.8.7. 我有一个现有的Rails 2.3.10应用程序,我正在考虑从1.8.7升级到Ruby 1.9.2。 Before I start hacking away at the application trying to get it to work, I'm trying to decide if it's even worth the effort. 在我开始攻击试图让它工作的应用程序之前,我试图决定它是否值得付出努力。

Just to get an idea of how much work might be involved, I'm simply running all the specs (rspec 1.3.1) in Ruby 1.9.2. 只是想知道可能涉及多少工作,我只是在Ruby 1.9.2中运行所有规范(rspec 1.3.1)。 98% of the tests are passing, but they run about 3x slower and there are a ton of messages like "Ruby 1.9 doesn't support Unicode normalization yet". 98%的测试都在通过,但是它们运行速度慢了3倍,并且有大量的消息,比如“Ruby 1.9还不支持Unicode规范化”。 I found a post about this issue , so I know I can fix it, but I'm concerned about the speed and other issues I might run into. 我发现了一个关于这个问题帖子 ,所以我知道我可以修复它,但我很担心速度和我可能遇到的其他问题。

My other option is to upgrade the application to Rails 3 and move to 1.9.2 at that time. 我的另一个选择是将应用程序升级到Rails 3并在那时移至1.9.2。 This seems like a much better decision for the long term, but could potentially be a lot more work. 从长远来看,这似乎是一个更好的决定,但可能会有更多的工作。

tl;dr - Should I upgrade to 1.9.2 now or wait until the application is on Rails 3? tl; dr - 我现在应该升级到1.9.2还是等到应用程序在Rails 3上?

I would recommend doing both, but the order in which you do them, or if you do them both at once is really a personal preference. 我建议同时做这两件事,但是你做这两件事的顺序,或者你同时做这两件事的顺序真的是个人偏好。 If you have a strong test-suite with good coverage this is a great first step in making the transition. 如果您拥有一个覆盖良好的强大测试套件,那么这是进行转换的第一步。 The main road-blocks you'll run into are the following: 您将遇到的主要障碍如下:

  • Many newer gem versions only support Rails 3, so if you are only doing one step at a time, make sure that you're gems are supported. 许多较新的gem版本仅支持Rails 3,因此如果您一次只做一步,请确保您支持宝石。 For example you don't want to get stuck in a situation where a gem requires you to upgrade because you are using Ruby 1.9.2 but the new version of the gem is only available in Rails 3. 例如,您不希望因为您使用Ruby 1.9.2而宝石需要您升级的情况而陷入困境,但新版本的gem仅在Rails 3中可用。
  • There are some syntax changes in Ruby 1.9.2 and compiled C extensions need to be re-complied or the gems re-installed. Ruby 1.9.2中有一些语法更改,需要重新编译已编译的C扩展或重新安装gem。
  • There are major application configuration changes from Rails 2.3 to Rails 3.0. 从Rails 2.3到Rails 3.0有重大的应用程序配置更改。 They take some time to complete but there is lots of support. 他们需要一些时间来完成,但有很多支持。

In general Ruby 1.9.2 will be faster than Ruby 1.8.7 and will provide some cool new syntax. 一般来说,Ruby 1.9.2将比Ruby 1.8.7更快,并将提供一些很酷的新语法。 If you are getting opposite results then I would benchmark your code and make sure that this is actually the case and that it's not just failing tests that are slowing your suite down. 如果你得到相反的结果,那么我会对你的代码进行基准测试,并确保实际上是这种情况,而且不仅仅是测试失败导致你的套件速度变慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM