Latest in branch 3.1
3.1.12
Released 18 Mar 2013
(13 years ago)
SoftwareRuby on Rails
Version3.1
Status
End of life
Initial release3.1.0
30 Aug 2011
(14 years ago)
Latest release3.1.12
18 Mar 2013
(13 years ago)
End of bug fixesUnavailable
End of security fixesUnavailable
Release noteshttps://github.com/rails/rails/releases/tag/v3.1.12
Source codehttps://github.com/rails/rails/tree/v3.1.12
Downloadhttps://github.com/rails/rails/releases/tag/v3.1.12
Ruby on Rails 3.1 ReleasesView full list

What Is New in Ruby on Rails 3.1

CategoryHighlights
New FeaturesAsset Pipeline (Sprockets), HTTP Streaming support, jQuery as default JS library, Identity Map (off by default), ParamsWrapper enabled for JSON, config.force_ssl middleware, Rack::Cache and Rack::ETag in default stack, engines can be mounted anywhere, rails plugin new command.
ImprovementsAsset pipeline configuration (compress, debug, digest), generators create CoffeeScript and Sass stubs, scaffold JSON format, http_basic_authenticate_with helper, form_for accepts method option directly, SafeBuffer mutation prohibited, HTML5 button_tag, data-* attribute generation, improved logging to STDOUT.
Breaking ChangesRequires Ruby ≥ 1.8.7 (1.9.2 recommended), RJS config removed, :cache and :concat options in asset helpers are ignored, auto_link extracted to external gem, rhtml/rxml template handlers removed, CSV fixtures deprecated, association destroy semantics changed, default jQuery gem must be added, config.action_dispatch.x_sendfile_header defaults to nil.
DeprecationsCSV fixtures, auto_link gem, rhtml/rxml handlers, old-style hash generation (still works but discouraged).

How does the new Asset Pipeline change asset management in Rails 3.1?

The Asset Pipeline introduces a unified, pre-processing pipeline for CSS, JavaScript, and images, powered by Sprockets.

All assets live under app/assets, lib/assets or vendor/assets. You declare dependencies with directives such as //= require jquery in application.js or *= require_tree . in application.css. During deployment, rake assets:precompile concatenates, minifies and fingerprints files, producing digested URLs like /assets/application-3f2c1e9c.css.

Configuration lives in config/application.rb and the environment files:

# config/application.rb
config.assets.enabled = true
config.assets.version = '1.0'

# config/environments/production.rb
config.assets.compress = true
config.assets.digest   = true
config.assets.compile  = false

In practice, this means you no longer need to manually manage cache-busting query strings or hand-roll concatenated files; the pipeline does it for you.

Why is jQuery the default JavaScript library in Rails 3.1?

Rails 3.1 ships with the jquery-rails gem and the application generator automatically includes jquery and jquery_ujs in the asset manifest.

To switch back to Prototype you can run rails new myapp -j prototype or replace the gems in the Gemfile. The new default reflects the broader community adoption of jQuery and provides unobtrusive JavaScript helpers out of the box.

Typical app/assets/javascripts/application.js now looks like:

//= require jquery
//= require jquery_ujs
//= require_tree .

This matters if your existing codebase relies on Prototype helpers; you'll need to update selectors and remote forms accordingly.

What is HTTP Streaming and when should I enable it?

HTTP Streaming lets the server begin sending the response body while still generating the rest of the page, reducing perceived latency for large pages.

It is opt-in, requires Ruby 1.9.2 or newer, and needs a web server that supports streaming (e.g., NGINX with Unicorn). Enable it per-controller with stream or by using ActionController::Live in Rails 3.1.

class PostsController < ActionController::Base
  stream
  def index
    response.stream.write "Chunk 1"
    # heavy processing ...
    response.stream.write "Chunk 2"
    response.stream.close
  end
end

Use streaming for dashboards, long-polling APIs, or any endpoint where early data delivery improves user experience.

What breaking changes should I watch for when upgrading to Rails 3.1?

Several APIs were removed or altered, so you need to adjust your code before the upgrade.

  • Ruby version must be ≥ 1.8.7; Ruby 1.9.1 segfaults, so upgrade to 1.9.2.
  • RJS configuration (config.action_view.debug_rjs) is gone; remove it from development.rb.
  • Asset helper options :cache and :concat are ignored; delete them from view helpers.
  • CSV fixtures are deprecated and will disappear in 3.2; migrate to YAML or factories.
  • Auto-link helper was extracted; add the rails_autolink gem if you still need it.
  • rhtml and rxml template handlers were removed; use ERB, Haml, or Slim instead.
  • Association destroy now only removes join-table rows for has_and_belongs_to_many and has_many :through; update any code that relied on the old behavior.
  • Default config.action_dispatch.x_sendfile_header is nil; configure it per server if you use X-Sendfile.

Most teams will need to run their test suite after these changes; the asset pipeline will also surface missing assets early.

Frequently Asked Questions

Does upgrading to Rails 3.1 require a newer Ruby version?
Yes Rails 3.1 requires Ruby 1.8.7 or higher and works best with Ruby 1.9.2.

How do I enable the Asset Pipeline in an existing Rails 3 app?
Add config.assets.enabled = true and config.assets.version = '1.0' to config/application.rb and include sass-rails, coffee-rails and uglifier gems in the Gemfile.

What gem replaces Prototype as the default JavaScript library?
The jquery-rails gem provides jQuery and the unobtrusive JavaScript adapters.

How can I force all requests to use HTTPS in Rails 3.1?
Set config.force_ssl = true in the appropriate environment configuration file.

Are CSV fixtures still supported in Rails 3.1?
No CSV fixtures are deprecated and will be removed in Rails 3.2.

How do I simplify basic HTTP authentication in controllers?
Use http_basic_authenticate_with name: "dhh", password: "secret", except: :index.

Releases In Branch 3.1

VersionRelease date
3.1.1218 Mar 2013
(13 years ago)
3.1.1110 Feb 2013
(13 years ago)
3.1.1008 Jan 2013
(13 years ago)
3.1.923 Dec 2012
(13 years ago)
3.1.809 Aug 2012
(13 years ago)
3.1.726 Jul 2012
(13 years ago)
3.1.612 Jun 2012
(13 years ago)
3.1.531 May 2012
(14 years ago)
3.1.5.rc128 May 2012
(14 years ago)
3.1.401 Mar 2012
(14 years ago)
3.1.4.rc122 Feb 2012
(14 years ago)
3.1.320 Nov 2011
(14 years ago)
3.1.218 Nov 2011
(14 years ago)
3.1.2.rc214 Nov 2011
(14 years ago)
3.1.2.rc114 Nov 2011
(14 years ago)
3.1.107 Oct 2011
(14 years ago)
3.1.1.rc306 Oct 2011
(14 years ago)
3.1.1.rc229 Sep 2011
(14 years ago)
3.1.1.rc114 Sep 2011
(14 years ago)
3.1.030 Aug 2011
(14 years ago)
3.1.0.rc829 Aug 2011
(14 years ago)
3.1.0.rc728 Aug 2011
(14 years ago)
3.1.0.rc616 Aug 2011
(14 years ago)
3.1.0.rc525 Jul 2011
(14 years ago)
3.1.0.rc409 Jun 2011
(14 years ago)
3.1.0.rc308 Jun 2011
(14 years ago)
3.1.0.rc207 Jun 2011
(14 years ago)
3.1.0.rc121 May 2011
(15 years ago)
3.1.0.beta104 May 2011
(15 years ago)