Rails 3.1: Release candidate
Posted by David May 22, 2011 @ 02:40 AM
As I promised at RailsConf, we’re finally good to go on the Rails 3.1: Release Candidate. This is a fantastically exciting release. We have three new star features and an even greater number of just awesome improvements. First the stars:
The Asset Pipeline
The star feature of 3.1 is the asset pipeline powered by Sprockets 2.0. It makes CSS and JavaScript first-class code citizens and enables proper organization, including use in plugins and engines. See my RailsConf keynote for a full tour. This comes with SCSS as the default for stylesheets and CoffeeScript as the default for JavaScript. Much documentation is on the way for this.
HTTP Streaming
This lets the browser download your stylesheet and javascripts while the server is still generating the response. The result is noticeable faster pages. It’s opt-in and does require support from the web server as well, but the popular combo of nginx and unicorn is ready to take advantage of it. There’s a great Railscast on HTTP streaming and the API documentation is strong too.
jQuery is now the default
We’ve made jQuery the default JavaScript framework that ships with Rails, but it’s silly easy to switch back to Prototype if you fancy. It’s all bundled up in the jquery-rails and prototype-rails gems. Just depend on the one you’d like in the Gemfile and it’ll Just Work.
Other good stuff:
- Reversible migrations: DRY migrations that know how to revert themselves. Cleaner, nicer migrations.
- Mountable engines: Engines can now have their own routing and helper scope. They can also take advantage of the asset pipeline (more documentation on this soon). Read the story behind mountable engines (even if the asset stuff is now out of date).
- Identity Map: It’s not enabled by default because of some important caveats that are still to be ironed out, but if you can deal with those, it’s a great way to cut down on the number of queries your app will trigger. Faster is better!
- Prepared statements: Active Record now uses cached prepared statements, which is a big boost for PostgreSQL in all cases and a boost for MySQL on complex statements.
- Rack::Cache on by default: This makes it possible to use HTTP caching with conditional get as a replacement for page caching (which we’ll soon factor into a plugin and remove from core).
- Turn test-output on Ruby 1.9: Much nicer test output courtesy of the Turn gem. It’s on with new applications by default on Ruby 1.9.
- Force SSL: It’s now easier than ever to keep your app safe with force_ssl. Either per-app or per-controller.
- Role-based mass-assignment protection: attr_protected now accepts roles, so it’s easier do deal with admin/non-admin splits and more.
- has_secure_password: Dead-simple BCrypt-based passwords. Now there’s no excuse not to roll your own authentication scheme.
- Custom serializers: Serialize objects with JSON or whatever else you’d like.
You can also check out the an even longer changelog and get a video overview from Railscast.
If you’re starting a new application, it’s strongly recommended that you do so using Ruby 1.9.2. Rails will continue to support 1.8.x until Rails 4.0, but it’s considered the legacy option. Ruby 1.9.x is where the action is. Get on board and enjoy the massive speed boost.
You can install the Rails 3.1: Release Candidate with gem install rails --pre. Enjoy and report any release candidate issues on Github. We expect to release the final version in a couple of weeks if all goes well.

Delivered as promised. Nice!
Hooray! Thanks for the work everybody!
Great news!! Thanks for the hard work!!
Loving CoffeeScript and SCSS.
Awesome work, guys!
Yeahh!!!! =)
Excellent. Great job everyone!
rapture with rc1!!!!
great way to end the world
Congrats guys! gem ‘rails’, ‘3.1.0.rc1’ :)
For those who use Textmate and want to develop using .SCSS check out my Textmate Bundle, which is the most advanced and useful bundle out there for SCSS Developers :)
https://github.com/kuroir/SCSS.tmbundle
Major props to the Core Team! This is almost worth a four-point-oh release!! :)
Rails rapture edition, sweet. Congratulations guys for making the life simple and awesome :)
Awesome! I think the this is the most sweet edition of Rails. CoffeScript , Saas and jQuery FTW!!!
Thank you guys for the hard work. :)
thanks guys
Such a nice release! Good job!
Hell Yeah!
Just started, $ rvm use 1.9.2 $ gem install rails—pre
GOOD
Stoked! Cant wait to get my hands dirty. Keep killin it David
The speed improvements gained by the prepared statement support under the SQL Server Adapter are huge! SQL Server already had a mechanism for taking advantage of cached query plans and ActiveRecord’s hooks to make this happen was a joy to implement. Thanks to everyone on core and especially Aaron for working on this feature!
Nice release!
BTW, anyone facing issues with jRuby ?
Did anyone try to upgrade from 3.0.7 to 3.1? Issues, any Gotchas?
Has anyone else been getting an error when installing activesupport-3.1.0.rc1?
Installing RDoc documentation for activesupport-3.1.0.rc1… ERROR: While generating documentation for activesupport-3.1.0.rc1 ... MESSAGE: incompatible character encodings: UTF-8 and ASCII-8BIT ... RDOC args:—op /home/cody/.rvm/gems/ruby-1.9.2-p180/doc/activesupport-3.1.0.rc1/rdoc lib—title activesupport-3.1.0.rc1 Documentation—quiet
I am impressed!!!!!!
Nice job, again!
Is the plan for Identity map to be turned on by default when 3.1 stable is released?
Great to have this version available. Impressive features and choices!
One thing that is probably worth mentioning, concerning switching between prototype-rails and jquery-rails, is that the prototype-rails gem actually includes both the UJS stuff and the RJS stuff, while the jquery-rails gem includes only the UJS stuff. If you need the RJS functionality using jquery-rails, you’ll also need to add jrails.
@Jason Toy, yes, identity map is turned on by default in Rails 3.1, and it’s awesome :-)
@Jason Toy, oops, didn’t realize this recently changed since the pre-release 3.1 rails app I was working on. Identity map is off by default :-(
Very nice, can´t wait to try out the new features. Congrats and a BIG thanks to everyone working on this fantastic release!
@Cody Russell, I’ve the same problem, cannot install activesupport rdoc due to incompatible character encodings: UTF-8 and ASCII-8BIT, the process has been stopped…
BTW congratulations for the release candidate, released as promised at railsconf !!!
Sweet!
Thanks for the Rapture edition of RoR3.1!!!
@Cody , @Tex
I get the same error. However, running gem install rails—pre a second (or third) time works for me.
Excited about the addition of Coffeescript.
Good job!
Wonderful!
Good Job!
Good Job!
Bloody thanks! Nice work, can’t wait to get everything upgraded. :)
thanks for scss & coffescript)
“1.9.x is where the action is. Get on board and enjoy the massive speed boost.” > massive speed boost, massive speed boost… when it’s booted because Rails takes several more seconds to boot than on 1.8. it seems to be a ruby bug thougth…
Amazing release! You’re awesome! Thanks!
Happy with this release. Good job guys.
And hurray for the identity map and for the mountable engines, and the role based mass assignement and god there’s too much goodness in there. thanks !
Thank you guys. A great upgrade again :)
@Cody, @Tex,
I hit the same error, but simply executing the command again worked. Thanks CBMeeks!
Great release indeed guys ! Hope we are close to the stable one :) This one looks pretty nice !
Thanks you guys for this release, This is great coz jQuery is default.
I’m getting this on every ActiveRecord call. It just seems broken:
ruby-1.9.2-p180 :003 > BlogPost.first (0.7ms) SHOW TABLES (1.7ms) describe `blog_posts` (0.3ms) SHOW TABLES ArgumentError: wrong number of arguments (3 for 2)
Back to 3.0.7, I suppose.
Hope sprokets and rake version incompability has been fixed. Rails 3.1 is awesome!
anyone else having trouble installing mime-types gem for rails3.1?
I’m on ubuntu 10.10 and I’m getting the following error message:
Fetching: mime-types-1.16.gem ( 97%)ERROR: While executing gem … (Gem::RemoteFetcher::FetchError) too many connection resets (http://production.cf.rubygems.org/gems/mime-types-1.16.gem)
I hope, there is way to disable usage of prepared statements? It’s not true, that it’s “big boost for PostgreSQL in all cases”: http://www.depesz.com/index.php/2008/05/10/prepared-statements-gotcha/
@Cody Russell: Yes, you’re not the only one getting a docbuild error. :-)
@Eric Heidelmark: I am having the same issue… any resolution?
@Eric Heidelmark – please update the mysql2 gem to the lates version – you have probably locked it to an older version, which isn’t compatible with rails 3.1. It worked for me.
Anyone else having problems with rails 3.1 on sub-URIs? seems like I keep getting links to ”/assets/” instead of ”/sub-uri/assets/”.(using passenger 3.0.7)
I’m trying to debug what’s going in actionpack, but I haven’t figured it out yet.
Replying to myself, in case anyone else is wondering:
It’s fixed on master, see https://github.com/rails/rails/commit/db5adf2d42d16859cde8f40e7b0b7fb41167cff4
Thanks Geoff Jacobsen ;-)
I’m getting the following when running gem install rails—pre on a fresh RVM gemset:
ERROR: While executing gem … (NameError) uninitialized constant Syck::Syck
Great job! Thank you for the hard work.
@Crhis Vincent: I was getting the same error, then after a few times trying to install rails 3.1 I now get:
ERROR: While executing gem … (NameError) uninitialized constant Psych::Syck
I’m also using a fresh gemset with rvm and ruby 1.9.2-head
@Chris Vencent, @Felix
Saw this too. I think it’s related to all the 3.0.8rc4 stuff going on right now.
I got around it by using
gem ‘rails’, ‘>=3.1.0.rc1’
in my Gemfile and doing a ‘bundle update’
Something is broken. Just tested under WinXP.
ruby -v ruby 1.9.2p180 (2011-02-18) [i386-mingw32]
gem -v 1.8.4
gem install rails—pre ERROR: While executing gem … (NameError) uninitialized constant Psych::Syck
jruby -v jruby 1.6.2 (ruby-1.8.7-p330) (2011-05-23 e2ea975) (Java HotSpot™ Client VM 1.6.0_25) [Windows XP-x86-java]
jruby -S gem install rails—pre ERROR: While executing gem … (ArgumentError) undefined class/module YAML::Syck::DefaultKey
While I rejoice for this release, I’m beeing more sceptical every day with my Ruby on Rails projects due the increasing lack of Windows Support….
believe it or not, but some people do actually develop & deploy on Windows Servers…
Can’t wait to kick the tires!
I’ve met the same
ERROR: While executing gem … (NameError) uninitialized constant Syck::Syck
issue with: gem install rails—pre
Get around with: gem install rails -v ”>=3.1.0rc”
thanks for the notice rchamp, worked for me after Syck error :)
YESSSS!! They finally make Sass and CoffeeScript default. This is ingenious!
One of the most exciting release in Rails history, in my humble opinion! Congratulations.
As an effort to get my hands dirty, I am trying out the 3.1 RC and apparently when trying to do a remote call (ajax) calling the controller such as this:
def remote_call render :update do |page| page << “alert(‘can you read me?’)” end end
It doesn’t work and throws a “Missing Template” error expecting “controller_name/update, application/update”
Can someone shed light to the render :update usage with jQuery as the default?
Many thanks in advance, Chad
image tag helper is not working
It is no use doing what you like ; you have got to like what you do .http://www.wealthtriggerreview.org/
Cool
CWT, apparently with rails_ujs no javascript rendering in controllers, so You have to use for example *.js.erb and render that view/javascript from controller or write ajax:complete ajax:success callbacks for a remote link in view file, which renders remote link/form.
render :text => “alert (‘uuuu’);” could do the trick, but it is not recommended way :)