将 Rails 应用程序从 1.2.3 升级到 3.1.0?

发布于 2024-12-09 14:11:32 字数 166 浏览 1 评论 0原文

我正在开发 Rails 1.2.3 版本。现在我想将Rails版本以及ruy版本从1.8.6升级到1.9.7。

使用这样的旧版本是不是很痛苦,但它处于运行状态。现在我想要 Rails 的高级功能,但不支持这个旧版本。

请建议我升级版本和ruby版本的方法。

谢谢....

I'm working on Rails 1.2.3 version. Now I want to upgrade the Rails version as well as ruy version from 1.8.6 to 1.9.7.

Is it a major pain to work with such older version but it is in running condition. Now i want advance features of Rails but not supporting this older version .

Please suggest me the way to upgrade the version and ruby version.

Thanks....

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

疯到世界奔溃 2024-12-16 14:11:32

这是一个很大的飞跃。您最好的选择是创建一个新的 Rails 3.1 应用程序,然后手动迁移代码。

gem install rails #=> will install the latest stable release from rubygems
gem install bundler
rails new myapp

您需要做的第一件事是打开 Gemfile 并添加您在当前应用程序中使用的任何 gem,最好找到任何插件的 gem 版本您正在使用(在 vendor/plugins 中)。还要确保您安装了适合您所使用的数据库类型的 gem(mysql2sqlite3pg)。

添加所需的所有 gem 后,运行 bundle install 将所有 gem 与您的应用程序捆绑在一起。

至于视图、模型和控制器,这些东西应该都可以复制到新应用程序中。您可能需要调整一些东西,但在大多数情况下,这些东西应该都可以工作。

您还需要打开 config/application.rb 并配置您的应用程序。您可以使用旧的 environment.rb 文件作为参考。

启动应用程序之前的最后一步是将 routes.rb 文件更改为新的 Rails 3 格式。这可能是迁移过程中最糟糕的部分,因为您首先需要学习如何编写 Rails 3 路由文件,然后手动写入路由。更多信息可以在此处找到。

我从未使用过 Rails 1,因此您可能需要更改一些其他内容。 这三个 Railscast 绝对是对您有用的资源。

That is quite a leap. Your best bet is to create a new rails 3.1 app and then manually migrate your code over.

gem install rails #=> will install the latest stable release from rubygems
gem install bundler
rails new myapp

The first thing you'll need to do is open up Gemfile and add in any gems you're using in your current application, and it would also be a good idea to find the gem versions of any plugins you're using (in vendor/plugins). Also make sure you have the proper gem installed for the type of database you're using (mysql2, sqlite3, or pg).

After you've added all the gems you need, run bundle install to bundle all the gems with your application.

As far as views, models, and controllers, that stuff should all be okay to just copy over to the new application. You will probably need to tweak a few things, but for the most part that stuff should all work.

You'll also need to open up config/application.rb and configure your application. You can use your old environment.rb file as a reference.

The last step before you can start your application is to change your routes.rb file to the new Rails 3 format. This is probably the worst part of migrating, as you'll first need to learn how to write a Rails 3 routing file, and then manually write in your routes. More information can be found here.

I never used Rails 1 so it's possible that you may have to change some other things. These three Railscasts will definitely be a helpful resource for you.

痴情 2024-12-16 14:11:32

我已将主要应用程序从 2.3.10 迁移到 3.0.9
这是一个非常痛苦的过程,如果我想迁移到 3.1,情况会更糟。

根据您的应用程序大小,我绝对建议创建一个新应用程序并复制内容。

从旧版本的 Rails 迁移到最新版本绝对不是一蹴而就的,有很多不同的事情需要考虑。

但是,关于我的答案最好的事情是我确实建议您这样做,测试过程,寻找兼容的 gem 等......在 Rails 3 和 ruby​​ 1.9.2 中要好得多

I have migrated a major application from 2.3.10 to 3.0.9
it's a very painful process and if I wanted to move to 3.1 it would have been even worse.

Depending on your application size, I would definitely recommend to create a new application and copy over the stuff.

Migrating from this old version of rails to the newest is definitely not in a single leap, there are so many different things to consider.

BUT, the best thing about my answer is that I DO recommend you do that, the process of testing, finding compatible gems etc... is so much nicer in rails 3 and ruby 1.9.2

温柔一刀 2024-12-16 14:11:32

哇,正如布里克所说,这是一个很大的飞跃!我很久以前就用过Rails 1..我没有升级到Rails 2,我重写了。

您的 Rails 1.2.3 应用程序有多大?

很多事情都发生了变化,Rails 中的功能、很多 Gem、路由、资产管道、命名范围、ActiveRecord 查询 API,...甚至 Ruby 也发生了变化——仅仅升级是一个坏主意。有许多新的概念和功能,您必须考虑这些,并且从头开始会更好。

这可能是因祸得福。我认为这对您来说是一个很好的机会,可以通过在 Rails 3.1 中重写和重新构建代码库来改进代码库:-)

我建议从头开始构建具有最关键功能的 Rails 3.1 应用程序,同时保留1.2.3 维护模式下的应用。

这可能也是摆脱应用程序的一些“功能”的好机会,这些“功能”几乎从未使用过......

wow, as bricker said, it's quite a leap! I used Rails 1 ages ago.. I didn't upgrade to Rails 2, I re-wrote.

How big is your Rails 1.2.3 application?

So many things have changed, features in Rails, so many Gems, Routing, Asset Pipeline, Named Scopes, the ActiveRecord Query API, ... even Ruby has changed -- it would be a bad idea to just upgrade. There are many new concepts and features, which you will have to think about, and it will be much better to start from a clean slate.

This can be a blessing in disguise. I think this is a great opportunity for you to improve your code base by re-writing and re-architecting it in Rails 3.1 :-)

I would suggest to start from scratch on the Rails 3.1 application with the most critical features, while keeping the 1.2.3 application around in maintenance mode.

It's probably also a good chance to get rid of some 'features' of your app, which are hardly ever used...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文