News from the edge of Rails.

What's New in Edge Rails #18

Week of April 15 - April 29, 2012

Well, two weeks actually, but who’s counting?

  • In 41af36f5 Rails moves from the unmaintained ruby-debug19 gem to the newer debugger fork - something you ought to do in any old projects as well.
  • rake notes gets updated in 55ceced1 to also look at your css, scss, and js files.
  • Rails routing gets a bit safer with 56cdc81c. This commit changes the router DSL to require an HTTP verb (or the override :via => :all) when using the match method.
  • 6acebb38b adds support for including multiple routes files from config/routes.
  • adff4a70 adds Rails.queue as a built-in queuing API that can (in the future) be hooked into by more advanced queues such as Sidekiq or Resque. This lead to a moderately large flame war in the commit comments but it looks like it’s here to stay. An important follow-on commit is cd50b604, which allows applications to have multiple distinct queues.
  • A batch of commits merged in 7d1a42a0 upgrade to the newest SQLite adapter. This is another fix you can make in your existing projects as well (just by swapping gems).
  • 76cd1ca0 lets you turn off Rails deprecation warnings entirely with ActiveSupport::Deprecations.behavior = :silence.
  • fcc534ed changes the behavior of validation errors on confirmation to render on the confirmation attribute instead of the original attribute.
  • The old button_to_function and link_to_function helpers are gone as of 3acdd652.

What's New in Edge Rails #17

Week of April 8 - April 14, 2012

Lots of tidying up in the Rails source this week. It’s amazing how much even a mature codebase can be improved when lots of people are nibbling away at it.

  • 1a20683f adds enough relations to NullRelation to make it chainable with database methods, so you can use Post.none anywhere you could use Post.all.
  • The FormBuilder class gets an index method in 47cbfbb9. Here’s the sample usage from the commit:

<%= form_for @person do |person_form| %>
  <%= person_form.fields_for :projects do |project_fields| %>
    Project #<%= project_fields.index %>
  <% end %>
<% end %>
  • 1bac04e85 optimizes the performance of #delegate. It’s a mildly-breaking change, though, in that you can no longer delegate to private methods.
  • With ca0af822, you get an automatic index when using references or belongs_to in migrations. That’s nice; it would have saved me typing add_index about eleventy-seven times by now.

What's New in Edge Rails #16

Week of April 1 - April 7, 2012

Although there were quite a few commits this past week, nearly all of them were to the docrails project, cleaning up the Guides and related documentation. On the new features front, Rails appears to have mostly taken a week off.

  • 99c08c70 cleans up some of the internals of url_for for faster operation - one of the hundreds of little performance and style tweaks going into the next version.

What's New in Edge Rails #15

Week of March 25 - March 31, 2012

Much of the work in edge Rails at the moment is concerned with cleaning up the code and making the Ruby better for the future. But there are still some new features coming down the pike.

  • 3e67e45dc327631e085cc67aaa6522b44324364c tweaks resource routing to be a bit more self-evident in the controllers through letting you define a custom parameter name to replace :id.
  • 4882271 cleans up Rails.initialized? to be simpler and more reliable.
  • The recent change to remote forms and authenticity tokens that was part of Rails 3.2.3 is also in master as 128cfbdf.
  • Active Record gets some new finders in 13b3c77e:
    • Post.find_by name: 'Spartacus', rating: 4
    • Post.find_by "published_at < ?", 2.weeks.ago
    • Post.find_by! name: 'Spartacus'

What's New in Edge Rails #14

Week of March 18 - March 25, 2012

Thanks to Ryan Daigle, this content now lives at If you have any ideas on other content that should be there, please drop me a line.

That said, it was a very quiet week in Rails master (or else I missed everything of significance. But here’s the one commit that caught my eye.

  • Eager-evaluated scopes are deprecated as of 0a12a5f8, in the hopes of avoiding some common and hard-to-find errors when using scopes.

What's New in Edge Rails #13

Week of March 11-March 17, 2012

The big news this week: Active Resource has been removed from Rails, and “API only” Rails applications put in a brief appearance before going back to the drawing board.

  • Text fields and text areas no longer have default size, rows, or cols as of 3384ee24. It’s 2012, if you want a default set it in your CSS.
  • eee32af45 adds a dynamic find_or_create_by_{attribute}! method to Active Record.
  • With f1637bf2 Active Resource has been removed from Rails. It will be available as a separate gem if anyone wants to maintain it, though I suspect most people who need that sort of functionality are using one of the alternatives already.
  • c1f397f88 merges a chunk of work to remove sprockets integration from Action Pack and depend on the sprockets-rails gem instead.
  • dde3058c7 removes the Active Record IdentityMap feature, which never worked right anyhow (see 302c912b for some details of the problems).
  • A bunch of commits starting at 4c16791f added “API only” Rails applications. All of them were reverted in 6db930cb because the feature is still half-baked.

What's New in Edge Rails #12

Week of March 4-March 10, 2012

It was a fairly quiet week in Rails master.

  • Another piece of mass assignment protection shows up in c97a1666, which prevents the association builder from assigning unexpected foreign keys.
  • e4e13883 adds a :layout option for partials that render a collection. Take a look at 6e0a763d for example usage.
  • On the Guides front we’re getting an instrumentation guide: see 4bfc8b1e.

What's New in Edge Rails #11

Week of February 26-March 3, 2012

The big news this week is the switch to requiring whitelisting all Active Record attributes by default. (See Double Shot #831 for some of the nonsense that led up to this). The impact is simple: you need to add an attr_accessible declaration to all of your models before update_attributes will change anything about them. You should have been doing this anyhow.

  • 641a4f62 turns on attribute whitelisting in Active Record by default. This is a change to Rails behavior.
  • ActiveModel::Model shows up in 3b822e91 as a way to make Active Model objects work directly with Action Pack. Documentation is in cb9d03f0.
  • 9b2c38b7 reduces the default connection pool size to 1 in new applications, trusting that people who need more for multithreaded applications will know what to do.
  • A little sugar: d6366625 adds last_year, last_month and last_week as aliases for the corresponding prev methods.
  • cd5dabab adds some optimization for path helpers. You won’t have to change anything in your code, but all _path and _url helpers speed up by a factor of 5 or so.
  • b8396578 features a bit of trolling due to a mass-assignment bug at GitHub. Removed a bit later in 2b74968f.
  • efd557a6 adds a new Guide for API-only applications. Note that some of the code in it hasn’t been implemented yet - something I’m not personally too keen about having in a Guide.

What's New in Edge Rails #10

Week of February 19-February 25, 2012

The biggest news this week comes on the REST front, with PATCH replacing PUT as the preferred verb for updating existing records. This has provoked some flaming and snarking (in which I have indulged), but on the whole I think it’s a reasonable change.

  • ad46884a adds support for the HTTP OPTIONS method to Rails integration tests.
  • 002713c6 adds support for the PATCH HTTP verb as well. According to the commit message “PATCH is the correct HTML verb to map to the #update action. The semantics for PATCH allows for partial updates, whereas PUT requires a complete replacement.”
  • As of abf3f67e you can configure whether Rails flushes the log every time your write to it. Turning off log autoflushing can improve performance if you’re willing to risk the loss of a few log writes.
  • force_ssl is no longer ignored by default in development. This is a change in behavior; c04a0847 has the details.
  • eecb086a2 gives us the start of a Guide for updating Rails.

What's New in Edge Rails #8

Week of February 5-February 11, 2012

Some goodies for PostgreSQL users this week, as well as other odds and ends.

  • As of d70e0236 Active Record supports PostgreSQL partial indexes. add_index(:accounts, :code, :where => "active") generates CREATE INDEX index_accounts_on_code ON accounts(code) WHERE active.
  • f7b915b5 adds support for PostgreSQL hstore columns.
  • Working with CoffeeScript gets just a tiny bit nicer now that rake notes picks up annotations from .coffee files in dd8c6f05.
  • I’m not convinced of its utility, but 60dad828 allows you to provide Float::INFINITY as an argument to validates_length_of.
  • A batch of commits replaced use of ActiveSupport::OrderedHash with pure Ruby 1.9 hashes.