Rails 3.1.0 has been released!

Hi everybody!

It’s been 3 Months since RailsConf, so I think it’s time we released
Rails 3.1.0. So, here it is! I’ve released Rails 3.1.0!

CHANGES

For a much more attractive and easy to read list of changes, please
check out the awesome Rails 3.1.0 Release Notes on the Rails Guides
site
. For a less
attractive list of changes, please continue to read!

In order to help you make the most of your time in understanding changes
for Rails 3.1.0, I’ve made a handy guide. Simply answer the following
question, and I’ll tell you where to get info about changes in Rails
3.1:

How much time do you have on your hands?

a) Not that much.

b) I have time to click some links and browse around for a bit.

c) I have way too much time on my hands.

If you answered a, then you should read the rest of this announcement.

If you answered b, then check out each of the CHANGELOG files checked in
to the Rails repository on github.

If you answered c, then please check out the commit list between Rails
3.0.10 and
3.1.0
.

Here are some highlights of the major changes in Rails 3.1.0:

ActionPack

  • ActionPack has been updated to include the new asset pipeline. Please
    see the rails guides on the asset
    pipeline
    .

  • Streaming response support has been added. This feature allows you to
    stream templates to the user before processing has actually finished.
    See the Rails Guides, or documentation in
    ActionController::Metal::Streaming for more information. Middleware
    have been refactored to support this feature.

  • RJS has been extracted to a gem.

ActiveModel

  • attr_accessible and friends now accepts :as as option to specify a
    role

  • Added ActiveModel::SecurePassword to encapsulate dead-simple
    password usage with BCrypt encryption and salting.

[ActiveRecord]

  • Prepared statement caches have been integrated.
    ActiveRecord::Base#create and simple finders will use a prepared
    statement and cache for more performant inserts and selects.

  • Associations have been refactored for greater simplicity and
    maintainability.

  • default_scope can take any object that responds to call.

  • PostgreSQL adapter only supports PostgreSQL version 8.2 and higher.

  • Migrations use instance methods rather than class methods. Rather
    than defining a self.up method, you should define an instance method
    up.

  • Migrations are reversible. When a new migration is generated, the
    migration will contain one method called change. Database changes
    made in this method will automatically know how to reverse themselves.
    For more information, see the documentation for
    ActiveRecord::Migration and
    ActiveRecord::Migration::CommandRecorder.

  • When a model is generated, add_index is added by default for
    belongs_to or references columns.

ActiveResource

  • The default format has been changed to JSON for all requests. If you
    want to continue to use XML you will need to set self.format = :xml in
    the class.

ActiveSupport

  • ActiveSupport::BufferedLogger set log encoding to BINARY, but still
    use text mode to output portable newlines.

  • Add Object#in? to test if an object is included in another object.

  • ActiveSupport::Dependencies::ClassCache class has been introduced for
    holding references to reloadable classes.

  • Added weeks_ago and prev_week to Date/DateTime/Time.

  • JSON decoding now uses the multi_json gem which also vendors a json
    engine called OkJson. The yaml backend has been removed in favor of
    OkJson as a default engine for 1.8.x, while the built in 1.9.x json
    implementation will be used by default.

Railties

  • The default database schema file is written as UTF-8.

  • Rack::Sendfile middleware is used only if x_sendfile_header is
    present.

  • Add alias r for rails runner.

  • jQuery is the new default JavaScript library.

  • Added config.force_ssl configuration which loads Rack::SSL
    middleware and force all requests to be under HTTPS protocol

SHA-1

  • b68f74ced662145a4139409edf3c51db1159ead8 actionmailer-3.1.0.gem
  • 136474f270677ae75ad0f9599d26e89cf1d4bc7b actionpack-3.1.0.gem
  • e6b68453c08bb0da52ed1d422ba2f87a5e3aa794 activemodel-3.1.0.gem
  • dfbae15c0d395304812c22fbf18aa9daadbe20b4 activerecord-3.1.0.gem
  • 3f1f547e500d1ffc1f7c3ee4ab9eb1526157a870 activeresource-3.1.0.gem
  • f21627c2f429abfa8685d2147fadab6704c13869 activesupport-3.1.0.gem
  • 21c6592189fb358a066846754a8f7ce7a238fca6 rails-3.1.0.gem
  • 79cfa1eca232de9a45453829287e4438089b7955 railties-3.1.0.gem

<3 <3 <3

On Wed, Aug 31, 2011 at 11:45 AM, Aaron P.
[email protected] wrote:

How much time do you have on your hands?

  • RJS has been extracted to a gem.

  • When a model is generated, add_index is added by default for belongs_to or
    references columns.

  • Rack::Sendfile middleware is used only if x_sendfile_header is present.

  • 136474f270677ae75ad0f9599d26e89cf1d4bc7b actionpack-3.1.0.gem
    Aaron P.
    http://tenderlovemaking.com/

Great work, thanks

Aaron P. wrote in post #1019311:

Hi everybody!

It’s been 3 Months since RailsConf, so I think it’s time we released
Rails 3.1.0. So, here it is! I’ve released Rails 3.1.0!

CHANGES

For a much more attractive and easy to read list of changes, please
check out the awesome Rails 3.1.0 Release Notes on the Rails Guides
site
.

Trying to read raw html is not awesome:

has_many
:things, :conditions => proc { ["foo = ?", bar] }

  • Previously :insert_sql and :delete_sql on has_and_belongs_to_many association allowed you to call ‘record’ to get the record being inserted or deleted. This is now passed as an argument to the proc.
  • Added ActiveRecord::Base#has_secure_password (via ActiveModel::SecurePassword) to encapsulate dead-simple password usage with BCrypt encryption and salting.
        
  • Schema: User(name:string, password_digest:string, password_salt:string) class User < ActiveRecord::Base has_secure_password end

7 Active Model

8 Active Resource

class User <
ActiveResource::Base
  self.format = :xml
end

9 Active Support

Deprecations:

10 Credits

See the full list of contributors to Rails for the many people who spent many hours making Rails, the stable and robust framework it is. Kudos to all of them.

Rails 3.1 Release Notes were compiled by Vijay D..

    <h3>Feedback</h3>
    <p>
      You're encouraged to help improve the quality of this guide.
    </p>
    <p>
      If you see any typos or factual errors you are confident to
      patch, please clone <a

href=“https://github.com/lifo/docrails”>docrails
and push the change yourself. That branch of Rails has public
write access.
Commits are still reviewed, but that happens after you’ve
submitted your
contribution. docrails is
cross-merged with master periodically.



You may also find incomplete content, or stuff that is not up
to date.
Please do add any missing documentation for master. Check the
Ruby on Rails
Guides Guidelines

for style and conventions.


And last but not least, any kind of discussion regarding Ruby
on Rails
documentation is very welcome in the rubyonrails-docs
mailing list.