Pelargir

Musings on software and life from Matthew Bass.

February 22nd, 2008

Is Communism really dead?

I found Misreading the Tea Leaves by J.R. Nyquist to be pretty thought-provoking. Maybe you will too.

February 21st, 2008

raleigh.rb has a podcast

Did you realize that Raleigh’s own Ruby Brigade now has a podcast? Yes ladies and gents, it’s true.

I’ve been recording the last few meetups on my MacBook. The audio quality isn’t half bad. I hope to expand the podcast in the future with non-meetup content. For now, it can serve as a good way to catch up if you’re out of town or otherwise can’t make it to our regular monthly meeting.

February 4th, 2008

Using named routes in Streamlined addition files

For you Streamlined users out there, here’s an easy way to include named routes in your Streamlined addition modules. Previously, you had to hard code the URLs like so:

module OrderAdditions
  def name_link
    link_to user.name, "/users/show/#{user.id}"
  end
end
 
Order.class_eval do
  include OrderAdditions
  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
end
 
Streamlined.ui_for(Order) do
  list_columns :name_link
end

By including Rails 2’s new ActionController::UrlWriter module, you can access any named or RESTful routes you’ve defined in routes.rb:

module OrderAdditions
  def name_link
    link_to user.name, user_url(user.id)
  end
end
 
Order.class_eval do
  ...
  include ActionController::UrlWriter
  default_url_options[:host] = APP_HOST
end

It would be nice for this to get baked into Streamlined somehow so UrlWriter automatically gets included, but until that happens this is a good way to get rid of those pesky hard-coded URLs.

February 4th, 2008