Forum: Ruby on Rails with_sorting

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
D689f1592faf0864644346f08bc70f5c?d=identicon&s=25 Adam Traver (atraver)
on 2006-12-29 01:52
(Received via mailing list)
I thought about posting this in the Ruby mailing list, but my basis for
comparison rests in Rails.

I currently have code that looks something like this:

<td><%= link_to("Name", { :sort => params[:sort], :dir => params[:dir]
}) %></td>
<td><%= link_to("Address", { :sort => params[:sort], :dir =>
params[:dir] }) %></td>

I came to the realization that adding a block to wrap those link_tos
and extract out the common elements might be worthwhile. It would
perform something like form_for or with_scope, it seems, and it would
look pretty darned good, too!

Unfortunately, both of those implementations rely on creating new
objects to yield the block to (and furthermore, my block/proc knowledge
isn't there yet), and it seemed like it might be too much work for not
enough reward.

Is there an easier way I'm not seeing? I can just do a for loop with a
list of values unique to each sortable field (e.g., link text, tag
title, etc.), but even that seems cludgy.

This topic is locked and can not be replied to.