Rails 3.2.0: Faster dev mode & routing, explain queries, tagged logger, store

Posted by David January 20, 2012 @ 05:22 PM

So we didn’t quite make the December release date as we intended, but hey, why break a good tradition and start hitting release targets now! In any case, your patience has been worldly rewarded young grasshopper: Rails 3.2 is done, baked, tested, and ready to roll!

I’ve been running on 3-2-stable for a few months working on Basecamp Next and it’s been a real treat. The new faster dev mode in particular is a major step up over 3.1.

Do remember that this is the last intended release series that’s going to support Ruby 1.8.7. The master git branch for Rails is now targeting Rails 4.0, which will require Ruby 1.9.3 and above. So now is a great time to start the work on getting your app ready for the current version of Ruby. Let’s not hang around old versions forever and a Sunday like those Python guys :).

There’s a v3.2.0 tag on Github and we of course we still have the 3-2-stable branch as well. You can see all the glorious details of everything that was changed in our CHANGELOG compilation.

For documentation, we have the 3.2 release notes with upgrade instructions, both the API docs and the guides have been generated for 3.2 as well, and there’s a brand new 3.2-compatible version of Agile Web Development with Rails. A smörgÃ¥sbord indeed!

Note: If you’re having trouble installing the gems under Ruby 1.8.7, you’ve probably hit a RubyGems bug with YAML that’s been fixed in RubyGems 1.8.15. You can upgrade RubyGems using “gem update—system”.

If you can’t be bothered with the full release notes, here’s a reprint of a few feature highlights from when we did the first release candidate:

Faster dev mode & routing

The most noticeable new feature is that development mode got a ton and a half faster. Inspired by Active Reload, we now only reload classes from files you’ve actually changed. The difference is dramatic on a larger application.

Route recognition also got a bunch faster thanks to the new Journey engine and we made linking much faster as well (especially apparent when you’re having 100+ links on a single page).

Explain queries

We’ve added a quick and easy way to explain quieries generated by ARel. In the console, you can run something like puts Person.active.limit(5).explain and you’ll get the query ARel produces explained (so you can easily see whether its using the right indexes). There’s even a default threshold in development mode where if a query takes more than half a second to run, it’s automatically explained inline—how about that!

Tagged logger

When you’re running a multi-user, multi-account application, it’s a great help to be able to filter the log by who did what. Enter the TaggedLogging wrapper. It works like this:

Logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
Logger.tagged("BCX") { Logger.info "Stuff" } # Logs "[BCX] Stuff" 
Logger.tagged("BCX") do
  Logger.tagged("Jason") do
    Logger.info "Stuff" # Logs "\[BCX\] \[Jason\] Stuff" 
  end
end

Active Record Store

Key/value stores are great, but it’s not always you want to go the whole honking way just for a little variable-key action. Enter the Active Record Store:

class User < ActiveRecord::Base
  store :settings, accessors: [ :color, :homepage ]
end
u = User.new(color: 'black', homepage: '37signals.com')
u.color                          # Accessor stored attribute
u.settings[:country] = 'Denmark' # Any attribute, even if not specified with an accessor

Posted in Releases | 67 comments

Comments

  1. Brian Cardarella on 20 Jan 17:24:

    Very nice! Looking forward to the faster dev mode

  2. Rob Conery on 20 Jan 17:27:

    Congrats team :).

  3. demiazz on 20 Jan 17:29:

    Good job! ) Thanks for RoR! ))

  4. Delwyn on 20 Jan 17:31:

    Thanks for all your hard work!

  5. Wez Pyke on 20 Jan 17:31:

    Awesome! Looks good.

  6. George Githinji on 20 Jan 17:31:

    great many thanks to the development team!

  7. kadeykin on 20 Jan 17:31:

    Yeah! Keep calm and keep pushing! ) I love you, rails dev team!

  8. Mark Fletcher on 20 Jan 17:33:

    Looking forward to trying out these new features

  9. James Daniels on 20 Jan 17:35:

    /highfive! Keep up the good work.

  10. Bryce Thornton on 20 Jan 17:36:

    Great work! Excited to give it a spin!

  11. AstonJ on 20 Jan 17:37:

    Awesome! Thanks all!

  12. Thiago Taranto on 20 Jan 17:37:

    Very cool, very nice! :)

  13. Luke Melia on 20 Jan 17:40:

    Congrats, dudes and dudettes! Looking forward to upgrading.

  14. Erik Dahlstrand on 20 Jan 17:40:

    Many thanks to Rails Core Team and all the contributors.

  15. hardy on 20 Jan 17:42:

    Grtttt!!!!!!!!!! excited to to try out new features….

  16. vijay suryawanshi on 20 Jan 17:44:

    awesome stuff, very nice :)

  17. TonyC on 20 Jan 17:53:

    Hooray!

    Another thing is that when config.activerecord.schema_format is set to :sql, you will get a sql dump file instead of a schema.rb. Yay!

  18. Venkata Reddy Bhavanam on 20 Jan 17:59:

    Thank you DHH and team!

  19. Jay Parteek on 20 Jan 18:00:

    Look forward to play with it.

  20. hron84 on 20 Jan 18:09:

    @TonyC this goes from 2.x branch… old joke.

  21. chris habgood on 20 Jan 18:38:

    bundle blows up on ruby 1.9.3-p0. rvm rails 3.2 ruby 1.9.3-p0.

    hemingway:base_app_3.2 chabgood$ bundle Fetching source index for https://rubygems.org/ /Users/chabgood/.rvm/rubies/ruby-1.9.3-p0/lib/ruby/1.9.1/net/http.rb:799: [BUG] Segmentation fault ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]

  22. Snuggs on 20 Jan 19:08:

    SHAZAMM!!!

  23. Clint Laskowski on 20 Jan 19:08:

    Congrats, RoR Team :-)

  24. josh susser on 20 Jan 19:12:

    Congrats on the release! Here’s a little write-up I did on the new modularized association methods: http://blog.hasmanythrough.com/2012/1/20/modularized-association-methods-in-rails-3-2

  25. Americo Savinon on 20 Jan 19:27:

    Looks Great! Rails keeps over delivering every single release.

  26. Derek on 20 Jan 19:30:

    Seems to require rubygems 1.8.15 or greater… https://github.com/rails/rails/issues/4559

  27. Martijn van Brandevoort on 20 Jan 20:12:

    Rails 3 has been nothing but amazing.. thanks to all contributors for this great new release!

  28. Luke on 20 Jan 20:16:

    W00t! Starting a new project…now!

  29. chez on 20 Jan 20:22:

    Queries, not “quieries”. Still good work guys!

  30. Aaron H. on 20 Jan 20:34:

    Just a word of warning if attempting to update a widely internationalized application.

    Most any routing add on (like i18n_routing) will be completely busted by the routing engine switch.

    Also, the new SafeBuffer changes will require changes anywhere you are calling a string method on text from a translated key.

    i.e. t(‘post.name’).titleize wil fail. t(‘post.name’).to_str.titlelize will work, though.

    Love the updates, but there are some caveats that aren’t completely clear from the release notes.

  31. Julio Alonso on 20 Jan 20:56:

    Awasome, thanks a lot to all contributors. RoR family is growing up quickly!!

  32. DMKE on 20 Jan 21:07:

    Well… ActiveSupport::TaggedLogger::ERROR is an uninitialized constant in https://github.com/rails/rails/blob/3-2-stable/activesupport/lib/active_support/tagged_logging.rb#L30 (can’t log in with neither Device 1.5.3, nor 2.0.0.rc nor master)

  33. saksmlz on 20 Jan 21:23:

    I have problems with ActiveSupport::TaggedLogger::ERROR, but without Devise

  34. Ariel De La Rosa on 21 Jan 03:20:

    Awesome, thanks so much to all the RoR family and friends!

  35. Trung LE on 21 Jan 03:51:

    Great work rails dev team, you guys keep me amazed again and again. Love you guys much

  36. Kevin Bedell on 21 Jan 04:14:

    The faster dev mode will be great—thanks to everyone who committed code!

  37. achat de viagra on 23 Jan 01:20:

    je me appontage cette limbes est-ce aisé d’être style dans écrire pur certains sujets partiellement personnels .. e.g ce auxquels vous-même débattez dos votre égérie et pour un détail jouer même jusqu’aux expériences intimes.. est-il facile par le faire parmi irréductible problème d’impuissance ?

  38. huangtuya@gmail.com on 23 Jan 03:35:

    very good. if json parser is more faster,it will be better.

  39. Justin on 23 Jan 05:54:

    Pretty cool stuff.Great work ROR team

  40. martinkaden on 23 Jan 08:14:

    Impressive post.Really very useful for me.thanks to ROR team

  41. seb on 23 Jan 09:08:

    Great work.

    Ruby on Rails make my days for years now and i’m still happy with each new real eases!

  42. Falk on 23 Jan 12:20:

    Awesome! ;)

  43. juhakaja on 23 Jan 13:44:

    Thank you and congratulations! Looking good as always.

  44. Tom Myer on 23 Jan 14:42:

    Thanks guys for the hard work. Sadly I have to wait until I have time to use/upgrade to 3.2… Anyway the additions look very nice!

  45. suanqi on 24 Jan 03:23:

    thanks ,ROR teams give us new release in chinese new year。

  46. Kevin Triplett on 24 Jan 04:52:

    LOVE THE FASTER DEV MODETHANKS!!!

  47. sahits@yahoo.com on 24 Jan 05:50:

    Rails Bulging…its accommodating all.. rails maybe a super one, not a super fast.

  48. marko on 24 Jan 09:28:

    Great work RoR team, updated a production app (after testing, of course) without any problems.

  49. yulrizka on 24 Jan 10:02:

    Thank you rails core team

  50. Panggi Libersa Jasri Akadol on 26 Jan 03:33:

    ah, more and more reason to upgrade.. thanks, kalian batu! (last two words are in Indonesian) :P

  51. ali bugdayci on 26 Jan 15:05:

    Great job. Continue with your great art.

  52. Moin Haidar on 26 Jan 17:03:

    Awesome! Thanks ;)

  53. Demonchand on 27 Jan 09:33:

    Thankyou Team

  54. Ravi Singh on 27 Jan 10:16:

    Thanks

  55. Sijo K George on 30 Jan 04:42:

    Many thanks to great ROR team.

  56. Kewin Wang on 30 Jan 10:16:

    The railway speed to release Rails

  57. Said Kaldybaev on 30 Jan 14:38:

    Thanks RoR team! waiting for “Journey engine” SYNOPSIS )))

  58. Matt Ledom on 30 Jan 16:05:

    I’m getting blank lines in the log output where I’m calling Rails.logger.debug { “print this message”} . Anytime I use the logger in code I get an a blank line. Is anyone else experiencing this. Our team is using 1.9.2 & 1.9.3 with Rails 3.2. This was not happening with Rails 3.1.3

  59. Ketan Doshi on 01 Feb 12:53:

    Great work!

  60. mansoor elahi on 02 Feb 08:57:

    Its great to see the dedication for an opensource projects… Hats off to all of you.. Keep up the good work..

  61. Alan Carl Brown on 07 Feb 21:40:

    Matt:

    Looks like curly braces no longer work. you can’t use:

    logger.debug {“oh no, curly braces don’t work no more?”}

    You have to go with:

    logger.debug “oh, now its working”

  62. Socialdex on 15 Feb 11:51:

    ROR FTW

  63. Victorias Secret Coupon Codes on 16 Feb 09:58:

    Super information it is actually. I’ve been looking for this tips.

  64. Tom on 16 Feb 10:00:

    Cool news it is surely. Friend on mine has been searching for this update. Victorias Secret Coupon Codes

  65. Tom on 16 Feb 10:02:

    Super share it is actually. I have been seeking for this content. Victorias Secret Coupon Codes

  66. Jay on 16 Feb 17:45:

    The application developed in Rails 3.2 is really awesome. Its on speed of rails.. very fast. The query explanations are helping us to decrease long queries. And Tagged logging is helpful especially when there is requirement of parsing logs for some purpose. We as rails community has taken a great step ahead with the new changes done in the application. Thanks for the info!!

  67. Maria on 17 Feb 22:18:

    This is a test comment, please respect it :) Kuriozitete te ndryshme