从 Rails 3 升级到 Rails 3.1

发布于 2024-11-06 17:53:49 字数 1459 浏览 0 评论 0原文

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

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

发布评论

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

评论(5

葬﹪忆之殇 2024-11-13 17:53:49

这就是在更新现有的 Rails 3.0.8 项目时对我有用的方法。您的情况可能会有所不同...

更新我的 Gemfile 中指定的 Rails 版本以使用最新的候选版本:

gem 'rails', '3.1.0.rc4’

更新捆绑包:

bundle update

然后使用 rake 命令更新项目:

rake rails:update

在挑选变更冲突后,我运行了所有测试并且它们通过了(耶!)。我重新启动了服务器,到目前为止一切似乎都很好。

然而,这还没有使用新的资产管道。我的意思是 javascript 和 css(或 sass)文件仍然以预管道方式处理。据我了解,这是一个完全可行的选择。但当然,我想要新的优点,所以我相信接下来的步骤是包含额外的 gems(例如 Coffeescript、sass、uglifier 等),然后将旧文件迁移到 app/assets 目录。

我在这里找到了一些详细信息:

http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/

希望有帮助。

This is what worked for me when updating an existing rails 3.0.8 project. Your mileage may vary...

Update the rails version specified in my Gemfile to use the latest release candidate:

gem 'rails', '3.1.0.rc4’

Update the bundle:

bundle update

Then update the project with the rake command:

rake rails:update

After cherry picking though the change conflicts I ran all my tests and they passed (yay!). I restarted the server and everything seems good so far.

However, this is not using the new asset pipeline yet. By that I mean the javascript and css (or sass) files are still being handled in the pre-pipeline manner. As I understand it, this is a perfectly viable option. But of course, I want the new goodness, so I believe the next steps are to include and additional gems (e.g. coffeescript, sass, uglifier, etc) and then to migrate the old files to the app/assets directory.

I found some details about that are here:

http://blog.nodeta.com/2011/06/14/rails-3-1-asset-pipeline-in-the-real-world/

Hope that was helpful.

娇女薄笑 2024-11-13 17:53:49

我刚刚从 3.0 升级到 3.1,将 Gemfile 更改为:

gem 'rails', '3.1.0.rc1'
gem 'sqlite3'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'

我还在 config/environments/development.rb 中注释掉了以下行

# config.action_view.debug_rjs = true

最后,请确保在 config/application.rb 中启用资产管道

config.assets.enabled = true

我不确定是否您已经阅读了发行说明 http://weblog.rubyonrails.org/2011/4/21/jquery-new-default

I just upgraded from 3.0 to 3.1 by changing my Gemfile to:

gem 'rails', '3.1.0.rc1'
gem 'sqlite3'
gem 'sass'
gem 'coffee-script'
gem 'uglifier'

I also commented out the following line below in config/environments/development.rb

# config.action_view.debug_rjs = true

Finally, make sure you enable the asset pipeline in config/application.rb

config.assets.enabled = true

I'm not sure if you've already read the release notes http://weblog.rubyonrails.org/2011/4/21/jquery-new-default

芸娘子的小脾气 2024-11-13 17:53:49

升级 Rails

更新:请谨慎使用系统 rake,因为 rake 已升级。

bundle exec rake

确保您将为给定的 Rails 项目使用正确的 Rake(


我建议从一个新的应用程序开始,然后复制您的特定应用程序信息,同时将您的资源转换为新的资产/链轮格式。

一个例子

转换较旧的 Rails 2.3.4 时
应用程序到 3.0 我崩溃并烧毁
一次更改一个文件
项目内。不用说
这是一个有缺陷的策略,但我做到了
一路上学习一点。我结束了
跳过 3.0 并转向 3.1beta1
使用新的应用程序,并复制我的应用程序
和公共文件夹后获得
迁移正确。那个举动有一个
有几个悬而未决的问题,其中最
重要的是我没有使用
Rails Edge 用于创建新应用程序
(感谢 RubyInside 的提示)。

首先将最新的 Rails 插入
易于参考的位置:

cd ~/goodtimes

git 克隆
https://github.com/rails/rails.git

我的路径包括 ~/Desktop/Dropbox/
所以我的代码随处可用。

然后参考rails exec
构建一个新的应用程序:

~/goodtimes/rails/bin/rails 新培根 --edge

根据数据库的复杂性,您要么想要使用更改语法创建新的迁移,要么保留它们是:

 class CreatePosts <; ActiveRecord::迁移
    定义改变
      create_table :帖子做 |t|
        t.string :标题
        t.文本:正文

        t.时间戳
      结尾
    结尾
  结尾

我在部署到 Heroku 时遇到了问题,但是 RubyRacer gem 帮助解决了这个问题。这是一个简单的 Gem 文件的示例:

source 'http://rubygems.org'

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

# Asset template engines
gem 'sass'
gem 'coffee-script'
gem 'uglifier'

gem 'jquery-rails'
gem 'pg'
gem 'therubyracer-heroku', '0.8.1.pre3', :platforms => :ruby

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

我怀疑会有社区实用程序来帮助您自动从旧版本的 Rails 迁移到 --edge。

参考资料:

  1. 如何使用 Rails 3.1、CoffeeScript 和现在所有的爵士乐
  2. Rails 3.1beta、Coffee-Script、jQuery、SCSS 和 Assets 的四骑士
  3. Rails 3.1beta 部署到 Heroku从您的 iPhone
  4. 可逆迁移

Upgrading Rails

Update: be cautious of using your system rake, as rake has been upgraded.

bundle exec rake

ensures you'll be using the correct rake for a given rails project (source)


I suggest beginning with a fresh app, then copying in your specific app information while shifting your resources into the new asset/sprockets format.

An example

While converting an older rails 2.3.4
app to 3.0 I crashed and burned while
changing one file at a time over
within the project. Needless to say
that was a flawed strategy, but I did
learn a little along the way. I ended
up skipping 3.0 and moving to 3.1beta1
with a fresh app, and copied my app
and public folders in after getting
the migrations right. That move had a
couple of outstanding issues, the most
important being that I didn’t use
rails edge for creating the new app
(thanks for the tip RubyInside).

First snag the latest rails into an
easy to reference location:

cd ~/goodtimes

git clone
https://github.com/rails/rails.git

My path includes a ~/Desktop/Dropbox/
so my code is available everywhere.

Then refer to that rails exec for
building a new app:

~/goodtimes/rails/bin/rails new bacon --edge

Depending on the complexity of your database, you'll either want to create new migrations using the change syntax or leave them be:

 class CreatePosts < ActiveRecord::Migration
    def change
      create_table :posts do |t|
        t.string :title
        t.text :body

        t.timestamps
      end
    end
  end

I had an issue deploying to Heroku, but theRubyRacer gem helped square that away. Here's an example of a simple Gem file:

source 'http://rubygems.org'

gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

# Asset template engines
gem 'sass'
gem 'coffee-script'
gem 'uglifier'

gem 'jquery-rails'
gem 'pg'
gem 'therubyracer-heroku', '0.8.1.pre3', :platforms => :ruby

# Use unicorn as the web server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

group :test do
  # Pretty printed test output
  gem 'turn', :require => false
end

I suspect there will be community utilities to help you automate migration from older versions of Rails to the --edge.

References:

  1. How to Play with Rails 3.1, CoffeeScript and All That Jazz Right Now
  2. The Four Horsemen of Rails 3.1beta, Coffee-Script, jQuery, SCSS and Assets
  3. Rails 3.1beta deployed to Heroku from your iPhone
  4. Reversible Migrations
找个人就嫁了吧 2024-11-13 17:53:49

我建议更新您的 Gemfile 以使用边缘导轨。例如:

gem 'rails',     :git => 'git://github.com/rails/rails.git'
gem 'arel',      :git => 'git://github.com/rails/arel.git'
gem 'rack',      :git => 'git://github.com/rack/rack.git'
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git'

gem 'sqlite3'

# Asset template engines
gem 'sass', '~> 3.1.0.alpha'
gem 'coffee-script'
gem 'uglifier'

您可以在此处阅读更多信息 http://pogodan.com/blog /2011/04/24/easy-edge-rails

I recommend updating your Gemfile to use edge rails. For example:

gem 'rails',     :git => 'git://github.com/rails/rails.git'
gem 'arel',      :git => 'git://github.com/rails/arel.git'
gem 'rack',      :git => 'git://github.com/rack/rack.git'
gem 'sprockets', :git => 'git://github.com/sstephenson/sprockets.git'

gem 'sqlite3'

# Asset template engines
gem 'sass', '~> 3.1.0.alpha'
gem 'coffee-script'
gem 'uglifier'

You can read more here http://pogodan.com/blog/2011/04/24/easy-edge-rails.

忘羡 2024-11-13 17:53:49

如果我正确理解你的问题,这就是:

gem install rails --pre

If i understood your question correctly this is how:

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