简体   繁体   English

如何使我的Ruby on Rails 2.3.4应用程序“Rails 3-ready”

[英]How can I make my Ruby on Rails 2.3.4 application “Rails 3-ready”

I'm developing an application with Ruby on Rails that I want to maintain for at least a few years, so I'm concerned about the next version coming up soon. 我正在使用Ruby on Rails开发一个我想要维护至少几年的应用程序,所以我很担心下一个版本即将推出。

Going from Rails 1 to Rails 2 was such a big pain that I didn't bother and froze my gems and let the application die, alone, in the dark. 从Rails 1走到Rails 2是一个巨大的痛苦,我没有打扰和冻结我的宝石,让应用程序独自死在黑暗中。

On this project I don't want to do that. 在这个项目上,我不想这样做。 First because this new version looks awesome , but also because this application may turn into a real product. 首先是因为这个新版本看起来很棒 ,但也因为这个应用程序可能变成一个真正的产品。

  • How can I prepare my application so that it will be upgradable with as little changes as possible. 如何准备我的应用程序,以便尽可能少地进行升级。

  • How time consuming do you think switching version will be? 您认为切换版本会耗费多少时间?

  • And what about my server? 那我的服务器怎么样? Deployment? 部署?

I'm already looking at deprecation notices... what else can I do? 我已经在考虑弃用通知......我还能做些什么?

The best thing you could do would be to follow development of Rails 3 via blogs and the Github repository and keep up a copy of your app along with it. 您可以做的最好的事情是通过博客和Github存储库跟踪Rails 3的开发,并随身携带应用程序的副本。

The official Ruby on Rails blog is updated with "What's new in Edge" posts every once in awhile. 官方的Ruby on Rails博客每隔一段时间更新一次“Edge中的新功能”帖子。 There are other blogs that often write about new things in edge as well. 还有其他 博客经常在边缘写下新事物。 Larger features are often highlighted in these blogs, so you know about all the cool new features you can play with. 这些博客中经常会突出显示更大的功能,因此您可以了解可以使用的所有酷炫新功能。

I'm not sure how close Rails 3 is to release (last I heard the core team was talking about a release at RailsConf 2009 in May), but you can always freeze the edge version of Rails into your application and just see what breaks. 我不确定Rails 3的发布有多接近(最后我听说核心团队正在讨论5月份在RailsConf 2009上发布的版本),但是你总是可以将Rails的边缘版本冻结到你的应用程序中,看看有什么破坏。 If you are using git, or another DVCS, you might make a branch specifically for Rails 3 and periodically update Rails to the latest edge code. 如果您正在使用git或其他DVCS,您可以专门为Rails 3创建一个分支,并定期将Rails更新为最新的边缘代码。 Just be aware that edge Rails is a moving target so things in your app may break or fix themselves as you are pulling in newer Rails code. 请注意,边缘Rails是一个移动目标,因此当您拉入较新的Rails代码时,应用程序中的内容可能会破坏或修复自己。

Update: Jeremy McAnally has a ton of info on upgrading from Rails 2 to Rails 3 on his blog. 更新:Jeremy McAnally在他的博客上有大量关于从Rails 2升级到Rails 3的信息。 http://omgbloglol.com/ http://omgbloglol.com/

I don't think there is going to be a major problem. 我不认为会有一个重大问题。 Going off what was said in that initial report the Rails team realized that they can't do a major rewrite like they did from 1 to 2. 关于初始报告中所说的内容,Rails团队意识到他们无法像1到2那样进行重大改写。

They even say: 他们甚至说:

I'm sure there'll be some parts of Rails 3 that are incompatible, but we'll try to keep them to a minimum and make it really easy to convert a Rails 2.x application to Rails 3. 我确信Rails 3的某些部分是不兼容的,但是我们会尽量将它们保持在最低限度,并且很容易将Rails 2.x应用程序转换为Rails 3。

I would be more concerned going from Merb to Rails 3. 我会更关心从Merb到Rails 3。

The single most important thing you can do to make it easy to migrate to a new version of rails is to have a comprehensive test suite. 为了便于迁移到新版本的rails,您可以做的最重要的事情就是拥有一个全面的测试套件。 Without a good test suite, I would never have the confidence that the new version of rails hasn't broken something in my app. 没有一个好的测试套件,我永远不会相信新版本的rails没有破坏我的应用程序中的某些东西。 On the current Rails app I'm working on, we started on Rails 2.1.1 back in October of 2008. Since then, we've migrated to Rails 2.1.2, 2.2.2, 2.3.2, 2.3.3 and now 2.3.4. 在我正在研究的当前Rails应用程序上,我们在2008年10月开始使用Rails 2.1.1。从那时起,我们已经迁移到Rails 2.1.2,2.2.2,2.3.2,2.3.3以及现在2.3.4。 I did the migrations to 2.3.2, 2.3.3 and 2.3.4...and for the 2.3.2 and 2.3.3 upgrades, we had some failing tests that alerted us to problems we would not have discovered without having such a good test suite. 我进行了迁移到2.3.2,2.3.3和2.3.4 ......对于2.3.2和2.3.3升级,我们进行了一些失败的测试,它们提醒我们在没有这样的情况下我们不会发现的问题好的测试套件。 The failing tests actually alerted us to a regressive bug in rails that there was a patch for on the Rails lighthouse but that was not included in the release (since it was discovered, right after the release). 失败的测试实际上提醒我们在Rails灯塔上有一个补丁的轨道中的回归错误但是发布中没有包含(因为它是在发布之后发现的)。

Once you've got that test suite in place, just stay current with each rails release (waiting a couple weeks to upgrade is fine, just don't skip any of the releases). 一旦你有了这个测试套件,只需保持最新的每个rails版本(等待几周升级就可以了,只是不要跳过任何版本)。

Yehuda Katz (a member of the Rails core team) has stated that there will most likely be a transitional release, containing deprecation warnings and such. Yehuda Katz(Rails核心团队的成员) 表示 ,很可能会有一个过渡性版本,其中包含弃用警告等。

So as long as you have a good test suite to expose the inevitable upgrade problems, and stay current with the Rails release, the migration to Rails 3 should not be too difficult. 因此,只要您有一个良好的测试套件来揭示不可避免的升级问题,并与Rails版本保持同步,迁移到Rails 3应该不会太困难。

As simple as: 很简单:

Great screencasts from Ryan Bates. 来自Ryan Bates的精彩截屏视频。

For preparing your application, the best way it what Jared said. 为了准备你的应用程序,Jared说的最好的方式。 Follow the Rails3 development. 按照Rails3开发。

For the time consuming, I think it depends of how you've followed the rails3 development before it's release. 耗时,我认为这取决于您在发布之前如何遵循rails3开发。

And for the deployment, it shouldn't take too much problems. 对于部署,它不应该带太多问题。 Rails 3 will be using Rack. Rails 3将使用Rack。 So you can start it with mongrel, passenger or any server/gateway it shouldn't give you any problem. 所以你可以用杂物,乘客或任何服务器/网关启动它,它不应该给你任何问题。

There are some major changes in Rails 3, I posted about my experience upgrading my app to Rails 3 here: http://rails3.community-tracker.com/permalinks/5/notes-from-the-field-upgrading-to-rails-3 Rails 3有一些重大变化,我发布了关于将我的应用程序升级到Rails 3的经验: http//rails3.community-tracker.com/permalinks/5/notes-from-the-field-upgrading-to-轨道-3

A good start in preparing would be to migrate over to using bundler. 准备工作的一个良好开端是迁移到使用捆绑器。 And doing a very deep review of strings that will go through the new XSS protection scheme. 并对将要通过新的XSS保护方案的字符串进行深入审查。

There are going to be some automated compatibility checkers. 将会有一些自动兼容性检查器。 Also, keep an eye on http://www.railsplugins.org/ so that you know if the libraries you depend on are going to be upgraded. 另外,请关注http://www.railsplugins.org/,以便了解您所依赖的库是否会升级。 The Rails Core team seems to be giving a lot of advance notice to the community this time around, so any lib that is actively maintained should be good to go. Rails Core团队似乎这次向社区提前通知了很多,所以任何积极维护的lib应该是好的。

Just do one thing 做一件事

take a backup of your old version project first and then 首先备份旧版本项目

on terminal(command prompt) write 在终端(命令提示符)写

rails new path/of/the/project

for example if my 2.3.* project is at home/rails_projects/myproject then 例如,如果我的2.3。*项目在home/rails_projects/myproject那么

rails new home/rails_projects/myproject

or 要么

cd home/rails_projects
rails new myproject

It will ask if there is any modifications done in any /config or other files. 它将询问是否在任何/config或其他文件中进行了任何修改。 Do appropriate. 做得恰当。

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

相关问题 如何向我的 Ruby on Rails 应用程序添加新视图? - How can I add a new view to my Ruby on Rails application? 如何在Rails应用程序中读取ruby中的siteminder标头 - How can I read siteminder headers in my ruby on rails application 如何在导轨 5 上的 ruby 的导轨中添加人脸识别? - How can i add a face recognition in my rails in ruby on rails 5? 使用Rails 3.0.5将红宝石升级到2.3.4 - Upgrading ruby to 2.3.4 with rails 3.0.5 如何在我的heroku托管的Ruby on Rails Web应用程序中调试“应用程序错误”? - How can I debug a “Application Error” in my heroku hosted Ruby on Rails web application? Ruby on Rails :(入门)如何使我的样式表(在public / stylesheet文件夹中)被布局使用? - Ruby on Rails: (Beginner) How can I make my style sheet (in public/stylesheet folder) be used by my layouts? 如何托管我的Ruby on Rails应用程序-没有托管提供商提供SQLite3数据库 - How can I host my Ruby on Rails application - no hosting providers offer SQLite3 database 如何在我的 ruby​​ on rails 视图中使用 erb 将引导程序字形作为按钮? - How can I use erb in my ruby on rails view to make a bootstrap glyphicon a button? 如何导出Rails应用程序中的红宝石 - How do i export my ruby on rails application 如何在 Ruby on Rails 应用程序中使用 Redis 和 Windows 操作系统? - How can I use Redis in my Ruby on Rails application with Windows OS?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM