This post originated from an RSS feed registered with Ruby Buzz
by Matthew Bass.
Original Post: Using named routes in Streamlined addition files
Feed Title: Pelargir
Feed URL: http://feeds.feedburner.com/pelargir/
Feed Description: Musings on software and life from Matthew Bass. Regular posts on new web products, tips and tricks, etc.
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 [...]