Forum: Ruby on Rails sort_link_helper and cross-controller partials

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.
D7cb4a1c32b57046567d5009e366f0cf?d=identicon&s=25 carp __ (carp)
on 2007-03-16 11:30
Hello Rubyists,

I ran into a problem with sorting a table (rendered in a partial) using
the sort_link_helper methods after I have submitted data and re-rendered
the table through an AJAX request.

The setup is a follows:

The table is a shared partial of Controller1 and Controller2 accessible
via "shared/table". The AJAX'ed sorting using the sort helper works all
fine on Controller1.

An AJAX link in the table refers to a method named "mymethod" on
Controller2. Controller2 does what is expected from it and does a render
:partial => "shared/table" and the table is correctly displayed.

However, the links generated by sort_link_helper change to the format of
instead of the expected (or desired)

The corresponding method in Controller2 looks like this:

def mymethod
  # ... some code
  if xhr?
    render :partial => "shared/partial", :layout => false

How can I tell the rendered partial to use links based on
"/controller1/list"? Thanks a lot in advance.
9a71df6388c8d37bfdf0e18742ea944a?d=identicon&s=25 AndyV (Guest)
on 2007-03-16 14:19
(Received via mailing list)
For a similar sort of problem I extended sort_link_helper, allowing it
to accept a hash of options.  I then used the options to override the
controller/action/etc as needed.  If you use a signature like:

sort_link_helper(text, params, options={}) you won't have to change
the code anywhere else.

This topic is locked and can not be replied to.