aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/upgrading_ruby_on_rails.md
diff options
context:
space:
mode:
authorPrem Sichanugrist <s@sikachu.com>2012-09-01 17:25:58 -0400
committerPrem Sichanugrist <s@sikac.hu>2012-09-17 15:54:22 -0400
commit872b7af337196febc516cb6218ae3d07f01a11a8 (patch)
treebc31fdc0803fff3aed26b6599cf2df7789055a41 /guides/source/upgrading_ruby_on_rails.md
parent7bc1ca351523949f6b4ce96018e95e61cbc7719e (diff)
downloadrails-872b7af337196febc516cb6218ae3d07f01a11a8.tar.gz
rails-872b7af337196febc516cb6218ae3d07f01a11a8.tar.bz2
rails-872b7af337196febc516cb6218ae3d07f01a11a8.zip
Convert heading tags and heading section
Diffstat (limited to 'guides/source/upgrading_ruby_on_rails.md')
-rw-r--r--guides/source/upgrading_ruby_on_rails.md55
1 files changed, 30 insertions, 25 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index 0f9a5f2f5a..44aca93718 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -1,18 +1,20 @@
-h2. A Guide for Upgrading Ruby on Rails
+A Guide for Upgrading Ruby on Rails
+===================================
This guide provides steps to be followed when you upgrade your applications to a newer version of Ruby on Rails. These steps are also available in individual release guides.
-endprologue.
+--------------------------------------------------------------------------------
-h3. General Advice
+General Advice
+--------------
Before attempting to upgrade an existing application, you should be sure you have a good reason to upgrade. You need to balance out several factors: the need for new features, the increasing difficulty of finding support for old code, and your available time and skills, to name a few.
-h4(#general_testing). Test Coverage
+### Test Coverage
The best way to be sure that your application still works after upgrading is to have good test coverage before you start the process. If you don't have automated tests that exercise the bulk of your application, you'll need to spend time manually exercising all the parts that have changed. In the case of a Rails upgrade, that will mean every single piece of functionality in the application. Do yourself a favor and make sure your test coverage is good _before_ you start an upgrade.
-h4(#general_ruby). Ruby Versions
+### Ruby Versions
Rails generally stays close to the latest released Ruby version when it's released:
@@ -22,7 +24,8 @@ Rails generally stays close to the latest released Ruby version when it's releas
TIP: Ruby 1.8.7 p248 and p249 have marshaling bugs that crash Rails. Ruby Enterprise Edition has these fixed since the release of 1.8.7-2010.02. On the 1.9 front, Ruby 1.9.1 is not usable because it outright segfaults, so if you want to use 1.9.x, jump on to 1.9.2 or 1.9.3 for smooth sailing.
-h3. Upgrading from Rails 3.2 to Rails 4.0
+Upgrading from Rails 3.2 to Rails 4.0
+-------------------------------------
NOTE: This section is a work in progress.
@@ -30,15 +33,15 @@ If your application is currently on any version of Rails older than 3.2.x, you s
The following changes are meant for upgrading your application to Rails 4.0.
-h4(#plugins4_0). vendor/plugins
+### vendor/plugins
Rails 4.0 no longer supports loading plugins from <tt>vendor/plugins</tt>. You must replace any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, <tt>lib/my_plugin/*</tt> and add an appropriate initializer in <tt>config/initializers/my_plugin.rb</tt>.
-h4(#identity_map4_0). Identity Map
+### Identity Map
Rails 4.0 has removed the identity map from Active Record, due to "some inconsistencies with associations":https://github.com/rails/rails/commit/302c912bf6bcd0fa200d964ec2dc4a44abe328a6. If you have manually enabled it in your application, you will have to remove the following config that has no effect anymore: <tt>config.active_record.identity_map</tt>.
-h4(#active_record4_0). Active Record
+### Active Record
The <tt>delete</tt> method in collection associations can now receive <tt>Fixnum</tt> or <tt>String</tt> arguments as record ids, besides records, pretty much like the <tt>destroy</tt> method does. Previously it raised <tt>ActiveRecord::AssociationTypeMismatch</tt> for such arguments. From Rails 4.0 on <tt>delete</tt> automatically tries to find the records matching the given ids before deleting them.
@@ -46,11 +49,11 @@ Rails 4.0 has changed how orders get stacked in +ActiveRecord::Relation+. In pre
Rails 4.0 has changed <tt>serialized_attributes</tt> and <tt>&#95;attr_readonly</tt> to class methods only. Now you shouldn't use instance methods, it's deprecated. You must change them, e.g. <tt>self.serialized_attributes</tt> to <tt>self.class.serialized_attributes</tt>.
-h4(#active_model4_0). Active Model
+### Active Model
Rails 4.0 has changed how errors attach with the <tt>ActiveModel::Validations::ConfirmationValidator</tt>. Now when confirmation validations fail the error will be attached to <tt>:#{attribute}_confirmation</tt> instead of <tt>attribute</tt>.
-h4(#action_pack4_0). Action Pack
+### Action Pack
Rails 4.0 changed how <tt>assert_generates</tt>, <tt>assert_recognizes</tt>, and <tt>assert_routing</tt> work. Now all these assertions raise <tt>Assertion</tt> instead of <tt>ActionController::RoutingError</tt>.
@@ -66,21 +69,22 @@ becomes
get 'こんにちは', :controller => 'welcome', :action => 'index'
</ruby>
-h4(#active_support4_0). Active Support
+### Active Support
Rails 4.0 Removed the <tt>j</tt> alias for <tt>ERB::Util#json_escape</tt> since <tt>j</tt> is already used for <tt>ActionView::Helpers::JavaScriptHelper#escape_javascript</tt>.
-h4(#helpers_order). Helpers Loading Order
+### Helpers Loading Order
The loading order of helpers from more than one directory has changed in Rails 4.0. Previously, helpers from all directories were gathered and then sorted alphabetically. After upgrade to Rails 4.0 helpers will preserve the order of loaded directories and will be sorted alphabetically only within each directory. Unless you explicitly use <tt>helpers_path</tt> parameter, this change will only impact the way of loading helpers from engines. If you rely on the fact that particular helper from engine loads before or after another helper from application or another engine, you should check if correct methods are available after upgrade. If you would like to change order in which engines are loaded, you can use <tt>config.railties_order=</tt> method.
-h3. Upgrading from Rails 3.1 to Rails 3.2
+Upgrading from Rails 3.1 to Rails 3.2
+-------------------------------------
If your application is currently on any version of Rails older than 3.1.x, you should upgrade to Rails 3.1 before attempting an update to Rails 3.2.
The following changes are meant for upgrading your application to Rails 3.2.2, the latest 3.2.x version of Rails.
-h4(#gemfile3_2). Gemfile
+### Gemfile
Make the following changes to your +Gemfile+.
@@ -94,7 +98,7 @@ group :assets do
end
```
-h4(#config_dev3_2). config/environments/development.rb
+### config/environments/development.rb
There are a couple of new configuration settings that you should add to your development environment:
@@ -107,7 +111,7 @@ config.active_record.mass_assignment_sanitizer = :strict
config.active_record.auto_explain_threshold_in_seconds = 0.5
```
-h4(#config_test3_2). config/environments/test.rb
+### config/environments/test.rb
The <tt>mass_assignment_sanitizer</tt> configuration setting should also be be added to <tt>config/environments/test.rb</tt>:
@@ -116,17 +120,18 @@ The <tt>mass_assignment_sanitizer</tt> configuration setting should also be be a
config.active_record.mass_assignment_sanitizer = :strict
```
-h4(#plugins3_2). vendor/plugins
+### vendor/plugins
Rails 3.2 deprecates <tt>vendor/plugins</tt> and Rails 4.0 will remove them completely. While it's not strictly necessary as part of a Rails 3.2 upgrade, you can start replacing any plugins by extracting them to gems and adding them to your Gemfile. If you choose not to make them gems, you can move them into, say, <tt>lib/my_plugin/*</tt> and add an appropriate initializer in <tt>config/initializers/my_plugin.rb</tt>.
-h3. Upgrading from Rails 3.0 to Rails 3.1
+Upgrading from Rails 3.0 to Rails 3.1
+-------------------------------------
If your application is currently on any version of Rails older than 3.0.x, you should upgrade to Rails 3.0 before attempting an update to Rails 3.1.
The following changes are meant for upgrading your application to Rails 3.1.3, the latest 3.1.x version of Rails.
-h4(#gemfile3_1). Gemfile
+### Gemfile
Make the following changes to your +Gemfile+.
@@ -145,7 +150,7 @@ end
gem 'jquery-rails'
```
-h4(#config_app3_1). config/application.rb
+### config/application.rb
The asset pipeline requires the following additions:
@@ -161,7 +166,7 @@ If your application is using an "/assets" route for a resource you may want chan
config.assets.prefix = '/asset-files'
```
-h4(#config_dev3_1). config/environments/development.rb
+### config/environments/development.rb
Remove the RJS setting <tt>config.action_view.debug_rjs = true</tt>.
@@ -175,7 +180,7 @@ config.assets.compress = false
config.assets.debug = true
```
-h4(#config_prod3_1). config/environments/production.rb
+### config/environments/production.rb
Again, most of the changes below are for the asset pipeline. You can read more about these in the "Asset Pipeline":asset_pipeline.html guide.
@@ -199,7 +204,7 @@ config.assets.digest = true
# config.force_ssl = true
```
-h4(#config_test3_1). config/environments/test.rb
+### config/environments/test.rb
You can help test performance with these additions to your test environment:
@@ -209,7 +214,7 @@ config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
```
-h4(#config_wp3_1). config/initializers/wrap_parameters.rb
+### config/initializers/wrap_parameters.rb
Add this file with the following contents, if you wish to wrap parameters into a nested hash. This is on by default in new applications.