# Sort\_link\_helper and cross-controller partials

**URL:** <https://www.ruby-forum.com/t/sort-link-helper-and-cross-controller-partials/88998>\
**Category:** Rails\
**Created:** [March 16, 2007, 11:30am UTC](https://www.ruby-forum.com/t/sort-link-helper-and-cross-controller-partials/88998 "2007-03-16T11:30:32Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![carp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@carp](https://www.ruby-forum.com/u/carp)\
**Post date:** [March 16, 2007, 11:30am UTC](https://www.ruby-forum.com/t/sort-link-helper-and-cross-controller-partials/88998/1 "2007-03-16T11:30:32Z")

</div>

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  
“/controller2/mymethod?aknownname=111802211&sort=my\_sort\_value”  
instead of the expected (or desired)  
“/controller1/list?sort=my\_sort\_value”.

The corresponding method in Controller2 looks like this:

def mymethod

# … some code

if xhr?  
render :partial =\> “shared/partial”, :layout =\> false  
end  
end

How can I tell the rendered partial to use links based on  
“/controller1/list”? Thanks a lot in advance.

---

<div class="post-metadata">

**Author:** ![carp](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/a8b319/32.png) [@carp](https://www.ruby-forum.com/u/carp)\
**Post date:** [March 16, 2007, 2:19pm UTC](https://www.ruby-forum.com/t/sort-link-helper-and-cross-controller-partials/88998/2 "2007-03-16T14:19:20Z")

</div>

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.

HTH,  
AndyV
