Week of May 7 - May 13, 2012
As usual, I’m only pulling out the things that look most interesting to developers using Rails; there’s a great deal of work still happening on Rails 4.0 internals. This work is valuable and necessary, but it’s the part of the iceberg that remains underwater for most Rails users.
Some time in the last week or two, by the way, Rails master passed 30,000 commits.
- ceb1dcc3 adds a default humans.txt to new Rails projects.
- b8f394f4 changes the behavior of Object#try to only use public methods of the target object.
ActiveRecord::Store allows you to specify the encoding for serialized attributes starting with 3c0bf043. This allows you to choose JSON, YAML, Marshal, or your own custom storage format.
Week of April 30 - May 6, 2012
Lots of code tinkering this week, but no huge new features. Here are a few highlights.
- 5c1109a6 adds a
-i option to the rails generator to skip building the index.html file that you always delete anyhow.
- 16e7f2f tweaks the Inflector code so that ‘police’ no longer singularizes to ‘polouse’.
ActiveRecord::Base#ids shows up in 93076168 - it’s like pluck specifically for the primary key of the main table.
- 07e5301e forces the
first finder to default to primary key order across all database engines. 489166e1 does the same for last. If you want the old behavior of first you can use take(introduced in 1379375f).
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.
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.
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.
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'
Week of March 18 - March 25, 2012
Thanks to Ryan Daigle, this content now lives at EdgeRails.info. 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.
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.
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.
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.