Posts tagged rails 3.0

Weekend Links

The usual round of Rails 3 updates: Pratik writes about the new Active Record Query Interface. I’ve had trouble with chaining nested scopes, so am very glad to see a better logic implementation, but the real win is that no queries are executed until the results are needed meaning that fragment caching suddenly gets much easier/more reasonable to use. Also on the new API front, Mikel has a piece on the new ActionMailer API which also seems much improved. Naturally with so many pieces about Rails 3 cropping up, posts are emerging linking as many as possible; Maxim Chernyak’s is the most comprehensive I’ve seen so far (though it’s missing my posts on the topic). If you’ve got a few hours free on February 18th, you may like to check out O’Reilly’s free online conference about Rails 3. And if you can’t wait to get started you might like to look at Jeremy McNally’s rails-upgrade gem that may help you on your way.

Caliper is a hosted version of the metric_fu gem, providing a very simple way to get lots of stats about your ruby app. I’ve had trouble getting metric_fu to run cleanly, so this could be a handy tool, though I’d rather get metric_fu properly integrated into my own Continuous Integration system. Speaking of which, my office mate Matt wrote up his experiences setting up Hudson for CI. I’m using Hudson too (partly thanks to Matt’s recommendations) and would highly recommend it.

I enjoyed reading about Tim Bray’s experience teaching his son and his classmates about blogging. Tim’s approach of having the students start by writing seems a great way to instil a positive vision of the web and also introduce a sense that web content isn’t necessarily to be trusted. On an entirely different note, I also enjoyed Russell’s brief piece “lowering the point point” arguing that:

Playing with something like Gowalla or Foursquare is worth doing – to see if it’s worth doing.

It’s been good to see Rachel Andrew blogging more frequently of late and I’m enjoying her pieces about running a small business. I’m particularly intrigued to see what responses come in to her piece about responding to tenders/RFPs as that’s a topic I’ve been wondering about lately too.

Google Sites suddenly becomes more interesting thanks to the addition of a Data API. On a not-entirely-unrelated note, I’ve been watching Tom release extractomatic and Paul release docent with some interest. It used to be that the potential ongoing work of maintenance was a disincentive to releasing tools that others might use, but things like Google App Engine and heroku really help with that.

Oh yes, Google are phasing out support for IE6. Could this be the move that pushes those last hold-out large institutions to upgrade to browsers created less than eight years ago?

More notes from a Rails 3.0pre upgrade

This is a follow-on from my piece on how I got the (development version of) Catapult Magazine up and running with Rails 3.0pre. If you haven’t already done so, I’d recommend you read that first.

Catapult makes use of the permalink_fu plugin which fails in Rails 3. It fails because of a reliance on the evaluate_attribute_method method which no longer exists in version 3. I’ve temporarily worked around that by replacing it with class_eval, but lately I’ve been using friendly_id a lot more and I suspect I’ll be focussing on porting to that if it works cleanly in Rails 3.

***

A dependency I’ve long wanted to part with is has_many_polymorphs. I’m using it to manage the categorisation of issues and posts but all that’s ever really saved me is one table/model, so perhaps now is the time to clean up the models and lose that dependency.

***

open_id_authentication uses a config.to_prepare block to include itself in ActionController::Base but that’ll work just as well if I add

include OpenIdAuthentication

to my ApplicationController, so that’s what I’ve done. I suspect a number of other changes will be needed (there’s a reference to config.gem in there) but so far, so good.

***

The key issue I’ve run into is that the init.rb files in my gem plugins aren’t run automatically, meaning that in addition, say, to declaring a model has_attached_file (for paperclip) I also need to require ‘paperclip’. That’s not totally unreasonable, but in a complex app it could be quite time consuming and begins to move away from the sense that a plugin/gem is a self-contained unit.

Looking through the new rails source I found the method that loads the init.rb files for plugins installed in vendor/plugins. Rails::Plugin::Vendored (in railties/lib/rails/plugin.rb) contains:

initializer :load_init_rb, :before => :load_application_initializers do |app|
  file   = "#{@path}/init.rb"
  config = app.config
  eval File.read(file), binding, file if File.file?(file)
end

but that only looks through those, not gem plugins. It wouldn’t be too hard to add some code in the initializer to glob the relevant folder and load those files but I’ve not had time yet to decide if that’s my best way forward.