Yehuda Katz is a member of the Ember.js, Ruby on Rails and jQuery Core Teams; his 9-to-5 home is at the startup he founded, Tilde Inc.. There he works on Skylight, the smart profiler for Rails, and does Ember.js consulting. He is best known for his open source work, which also includes Thor and Handlebars. He travels the world doing open source evangelism and web standards work.

Rails Dispatch

It’s been a busy week or two. I just got back from acts_as_conference, which was a blast. I got to talk about “The Merge”; the talk was 50% prepared slides and 50% Q&A. I’m glad I did it that way, since the questions were (as usual) great. DHH did Q&A in the morning of the first day, and fielded some questions about the merge as well. He also took questions on a bunch of other topics (“Do you Test All the Fucking Time?” “No.”).

On the Rails front, I continue to wrestle with callbacks. On the bright side, once it’s all done, there will be a single, uniform callbacks interface for every callback use in the Rails codebase. That includes ActiveRecord callbacks, Dispatch callbacks, Test::Unit callbacks, and of course, before/after/around filters. Once I’m ready, all of the above will have around filters, the biggest obvious change, and they’ll also all be much faster in the face of a number of callbacks.

I’ve completed integrating the new callbacks into Test::Unit and ActionController::Dispatcher, and am in the process of merging them into AP. However, I’m going to take a break for a few days from it and see about extracting AbstractController (I’m stuck in a rut with the integration and need to take a step back for a bit).

On another topic, we had a discussion today about how to handle http parameters when there are multiple parameters with the same name (but without “[]“). I should have a patch to handle this later tonight. Stay tuned!

4 Responses to “Rails Dispatch”

Nice progress indeed.

Looking forward to read more on progress very often.

Thanks for helping in making Rails 3.0 more and more powerful day by day.

Would you consider an Active Record validation to be a callback? I’ve been trying to discern the difference, and lately I feel like they’re essentially just a special kind of sugary callback.

Yep! ActiveRecord callbacks are yet another kind of callback :)

  module Validations
    VALIDATIONS = %w( validate validate_on_create validate_on_update )

    def self.included(base) # :nodoc:
      base.extend ClassMethods
      base.class_eval do
        alias_method_chain :save, :validation
        alias_method_chain :save!, :validation
      end

      base.send :include, ActiveSupport::Callbacks
      base.define_callbacks *VALIDATIONS
    end

I’m thrilled to hear about callback unification/generalization in Rails. It’s an idea whose time has come. Part of my inspiration for HookR was wanting to have a callback API which wasn’t bound to any particular library. Is there any chance the Rails callback code will be factored out into a standalone library?

Leave a Reply

Archives

Categories

Meta