As I''ve had no reply, I guess the answer is no - there isn''t
an existing
method. I''ve thrown these helper methods together which does the job
for
me:
  def image_map_for_sort_link(name, field)
      params_for_link = params.clone
      params_for_link.delete_if{|key,value| key == ''order'' or
key ==
''sort_by''}
      output = Array.new
      output << [''<map name="'', name,
''">''].join
      output << image_map_area("0,0,20,18", url_for(:sort_by
=> field,
:params => params_for_link, :order => ''asc''))
      output << image_map_area("20,0,40,18", url_for(:sort_by
=> field,
:params => params_for_link, :order => ''desc''))
      output << ''</map>''
      return output.join("\n")
  end
  def sort_image(field="")
    map_name = "sort_#{field}"
    @image_maps = Array.new unless @image_maps
    @image_maps << image_map_for_sort_link(map_name, field)
    image_tag(''sort.png'', :usemap =>
"##{map_name}", :class =>
''image_map'')
  end
  private
  def image_map_area(coords, url)
    [''<area shape="rect" coords="'', coords,
''" href="'', url, ''"
/>''].join
  end
The result is that adding <%= sort_image(''field_name'')
-%> to a view
adds a clickable sort image, as long as I also have <%= @image_maps %> 
somewhere on the page. I also have to handle params[:sort_by] and 
params[:order] in the controller to handle the sorting.
-- 
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---