• Living on the Edge (of Rails) has a new home at the Official Ruby on Rails weblog

    You may have heard of it, but just in case, Living on the Edge is now going to be published on the official Ruby on Rails weblog. Big thanks to Gregg Pollack for getting me the new "gig", and more importantly, for reviving and freshening up the content on the official Rails blog.

    Catch the new first edition - this one's about the API changes since Rails 2.1.

  • RailsConf 2008 Day 1 - pics and a summary

    Day 1 of RailsConf 2008 was basically tutorial day (schedule) and started with my colleague here with me, Arun, missing out on Yoga on Rails and me sleeping until the first tutorial session. Anyway, I snapped some photos while trying to remain the unobtrusive tourist.

    Here's a shot of Portland Convention Center where it's all happening:

    Portland Convention Center - twin peaks outside

    There're queues for collection of badges after registering your attendance:

    RailsConf Day 1 - registration queue

    Patience in the queue rewarded me with a RailsConf badge/name tag:

    RailsConf badge

    I was at the Meta-programming Ruby for Fun & Profit tutorial in the morning. I think when I selected the tutorial it was before I'd seen Neal Ford and Patrick Farley's (the speakers) presentation videos from elsewhere - I know Patrick presented at MWRC and enjoyed that video.

    RailsConf day 1 - metaprogramming tutorial

    So anyway, after the break I went over to the Refactoring Your Rails Application tutorial. Was pretty good, but I didn't learn much I didn't already know.

    Lunch came in the form of a pretty box:

    RailsConf day 1 - lunch

    After lunch was the 2nd tutorial session and I went to both CI for the Rails Guy (or Gal) (by Chad Woolley) and Developer Testing Tricks (by Brian Takita). There were some scathing comments about how the tutorials were rather underwhelming so far in #railsconf on IRC. While I agree that the tutorials were rather underwhelming, I think I should have expected it. Oh well, I'll know to skip them next time.

    Later that night, at the Birds of a Feather session, after stealing a Pivotal Labs t-shirt (they're launching a bug tracker, project management type app called Pivotal Tracker at RailsConf), Yehuda Katz (Merb and jQuery ninja) gave a presentation on Merb (geared towards Rails folks). It was a pretty interesting talk though there wasn't much above what Ezra had presented previously at GoRuCo 2008 and at MWRC 2008 (I think Yehuda did one too but I can't remember where now). Yehuda pointed out a (heated) discussion that happened recently on keeping Merb syntax as Rails-friendly as possible. I have no objection against a different syntax really, especially since Merb looks pretty well-documented in the source itself - would be nice if someone could point out an up-to-date Merb tutorial though.

    Anyway, that's it from me - as always, if anyone who reads my blog recognizes me at RailsConf, do say hi (#railsconf works too).

  • Living on the edge (of Rails) #22 - pre-Railsconf 2008 edition

    No mind-blowing changes in Rails this week prior to RailsConf - as Gregg mentioned last week in the Rails Envy podcast, it's pre-2.1 days (Rails 2.1 will probably be released at RailsConf) so it's pretty easy to see why. Oh and all Rails tests now pass in Ruby 1.9 after a long-standing #module_eval bug got fixed in Ruby 1.9's trunk (see thread for more details).

    I'll be at (my first) Railsconf 2008 in Portland, Oregon this Thursday onwards - if anyone sees me and recognizes me from my Facebook picture please come and say hi (no head butting though).

    This week’s report covers changes from 19th May 2008 to 25th May 2008 (the day the corresponding Rails Envy podcast was recorded).

    first and last methods now work with associations and named_scope

    Remember how the merging of the has_finder gem into Rails allowed you to do things like Post.first and Post.last?

    Now you can go one step further and use the same methods on your ActiveRecord associations. For example:

    post = Post.find(1)
    first_comment = post.comments.first

    If you have a named_scope named recent defined, you can even do this:


    This neat little enhancement is courtesy of Ryan Bates (yes, that Ryan Bates of Railscasts fame).

    Related changeset: http://github.com/rails/rails/commit/73c59638549686fccc749ffd3ac53cb533c5fd61

    Cache stores now have an exist? method and controllers get fragment_exist?

    The cache stores in Rails (Memcache, file stores, etc.) now have an exist? method that checks whether a cached value exists given a cache key. This allows Rails controllers to expose a fragment_exist?
    method that allows you to check for existence of a cache fragment:


    This little enhancement is courtesy of José Valim.

    Related changeset: http://github.com/rails/rails/commit/99860b72aebe0348f41e82d4710343498d89a84b#diff-2

    Create association records with block argument

    You can now create records for associations like so:

    post.coments.create!(:title => 'Techcrunch') do |c|
      c.body = "Rails can't scale"

    This is in keeping with the ActiveRecord::Base.create change previously mentioned.

    Credit for this patch goes (once again) to Ryan Bates.

    Related changeset: http://github.com/rails/rails/commit/6cba97d2a449faf21aec9fe9d4434067e414226f

    As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series.

  • Living on the Edge (of Rails) in Spanish

    Juan Lupión wrote in to inform me that he's also translating my Living on the Edge (of Rails) series of blog posts to Español. Thanks Juan!

  • Living on the edge (of Rails) #21

    It's another slow week (just 2 changes of note imho) after the release of the 1st Release Candidate (RC1) of Rails 2.1. Follow that link for installation instructions - though if you're reading this blog post you probably don't care! (because you're, you know, "living on the edge"). Cheesiness aside, be sure to report any bugs you may encounter when upgrading to 2.1 RC1 or edge at the Rails bug tracker - it is an RC so any bug reports would be very welcome and useful!

    This week’s report covers changes from 12th May 2008 to 18th May 2008 (the day the corresponding Rails Envy podcast was recorded).

    caches_action can has conditionals

    caches_action now takes an :if option (just like caches_page does). For example:

    caches_action :index, :if => Proc.new { |c| !c.request.format.json? }

    This little enhancement is courtesy of José Valim.

    Related changeset: http://github.com/rails/rails/commit/7708650f73ddb4db300ea2059c60c1d907a4384e

    Bugfix: :select option is now scanned in ActiveRecord finders to ensure needed tables are included in generated SQL

    Post.find(:all, :include => :author, :select => 'posts.*, authors.id as "author_id"', :limit => 2)

    Would generate an SQL statement like this:

    SELECT posts.*, authors.id as "author_id" FROM "posts" LIMIT 2

    Notice how the authors table is not joined. This oversight is now fixed.

    Thanks go to John Devine for this bugfix.

    Related changeset: http://github.com/rails/rails/commit/b28b54cab090bed8f099ef375b419a8f92390dd4

    As always, let me know of any suggestions or how I can improve the Living on the Edge (of Rails) series. Also, if anyone has any recommendations of (non-ruby-related) things to do in Portland, do let me know!

subscribe via RSS