News from the edge of Rails.

What's New in Edge Rails #28

Week of July 2 - July 8, 2012

This week also featured a bunch of noodling around with test harness internals, but that’s sort of endemic to any ruby project.

  • More statements for migrations: add_reference and remove_reference (aliased to add_belongs_to and remove_belongs_to as well). These are reversible, and take care of the columns and indexes, even in polymorphic cases. The changelog is at 17d2115e.
  • edaa2c48 introduces an easier syntax to set ActionMailer defaults in your config files.
  • 238a4253 finally adds support for defining your own flash types, in case :notice and :alert aren’t what you prefer.
  • When you hit a RoutingError in development, you will automatically see your defined routes as of fa714ec7.

What's New in Edge Rails #27

Week of June 25 -July 1, 2012

Another 4.0 article for more in-depth reading than my notes here: Rails 4.0 Sneak Peek: Asynchronous Action Mailer.

  • dc7fd821 is the commit that brings asynchronous Action Mailer via the Rails queue to the code. It’s followed by some code cleanup and then documentation in 6a859152.
  • The doc change in 24a4cc74 serves as a reminder that Rails 4.0 will require Ruby 1.9.3 or higher.
  • 94b230e1 adds a polymorphic option to the model generator: rails g model Product supplier:references{polymorphic}.
  • 5e7d6bba reverts an earlier commit, removing support for loading multiple external route files as part of config.rb. That’s why it’s called edge, folks.

What's New in Edge Rails #26

Week of June 18 -June 24, 2012

Seeing a few more Rails 4.0 articles lately, like Brian Cardarella’s Rails 4.0 Sneak Peek: Queueing.

  • 052e415f dials the default PostgreSQL log level back to warning, to get rid of some excess log noise.
  • The ActiveRecord composed_of feature gets dropped in 14fc8b34. The commit message shows you what you can replace it with.
  • ActiveRecord::Relation#pluck can now handle multiple columns. The work is merged in d59b2ab5c1dfc0e90d0c735a06c4607e7db07e65.

What's New in Edge Rails #25

Week of June 11 -June 17, 2012

This week saw the first commits designed to handle Ruby 2.0 compatability - a rather scary thought.

  • 02b2335 modifies the connection pool to make sure that the thread that has been waiting the longest gets the next available connection.
  • a7f4b0a1 is one of those changes that’s going to affect every application I’ve ever written: it removes update_attribute in favor of update_column.
  • PostgreSQL’s native uuid data type is supported with 12e9a75f.
  • 75714082 merges a bunch of changes to get logic out of the various rake db tasks, and encapsulated into classes and objects.

What's New in Edge Rails #24

Week of June 4 -June 10, 2012

Not a very busy week.

  • The work merged at b4fb80cb starts reducing the number of strings that Rails creates; in the long run, this should have a good effect on memory/GC issues.
  • 4faaa811 adds ActiveRecord::Base#destroy! which raises an exception if the record cannot be destroyed.
  • 96f19f6c raises an error in dev mode if there are pending migrations, rather than waiting for your code to fail because the database is out of sync with the code.

What's New in Edge Rails #23

Week of May 28 -June 3, 2012

It was a fairly quiet week on the Rails front. Well, if you don’t count multiple non-edge dot releases for security fixes.

  • f9cb645d lets you use a block with Active Record counts: Person.where("age > 26").count { |person| gender == 'female' }.
  • 5db367a7 changes the default Gemfile template to use 1.9 hash syntax, which I think is ugly as sin in this case. gem 'capistrano', group: :development. I hate the stuttering colons.
  • rake stats reports on code lines in Javascript and CoffeeScript files with a48b3f1a.
  • 806d023b adds Rails 4.0 release notes to the tree - a sign that things are moving along, I suspect.

What's New in Edge Rails #22

Week of May 21 - May 27, 2012

In addition to the features I’ve called out below, there’s still plenty of internal tinkering going on with Rails 4.0. This week included some work on deep methods to manipulate hashes and removing a batch of dependencies on Pathname.

  • 43fa48e5 moves the root route to the top of the generated routes.rb file. I’m mildly surprised that this hasn’t spawned another flame war.
  • As of 1ce4b5b3 and b02d14aa there is broader helper support for various HTML5 input types, including color, month, week, datetime, and datetime-local.
  • You can use the /rails/info/routes path in development to show the equivalent of rake routes in the browser starting with cb44e0fe.

What's New in Edge Rails #21

Week of May 14 - May 20, 2012

In addition to the code changes below, I want to mention the contributors to docrails, who are doing a great job of keeping the Guides up to date with the edge code. Check out their work at http://edgeguides.rubyonrails.org/.

  • 683fc4db changes :disable_with to data-disable-with in various tag helpers for consistency with other attributes handled by the unobtrusive JavaScript drivers. dd42e890 further tweaks this to use the :data => { :disable_with => ... } form of the API in examples.
  • With 3f352d04 Model.pluck supports SQL fragments (such as DISTINCT name as well as attribute names.
  • You can now tell Rails to pass templates through undisturbed by using the .raw extension, as of 8bea6072.
  • 446940c3 brings in helpers for the HTML5 time input tag.
  • Check the changelog update in 103ce300 for details about the deprecation of most dynamic finder methods in Active Record, and how to rewrite them in your code. No rush on this because they won’t be gone until Rails 5.0, but it’s good to stay up to date.

What's New in Edge Rails #20

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.

What's New in Edge Rails #19

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).