# Controlling the URL generated after an action is performed

**URL:** <https://www.ruby-forum.com/t/controlling-the-url-generated-after-an-action-is-performed/137278>\
**Category:** Rails\
**Created:** [May 11, 2008, 10:11am UTC](https://www.ruby-forum.com/t/controlling-the-url-generated-after-an-action-is-performed/137278 "2008-05-11T10:11:16Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jtoly](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/b9bd4f/32.png) [@jtoly](https://www.ruby-forum.com/u/jtoly)\
**Post date:** [May 11, 2008, 10:11am UTC](https://www.ruby-forum.com/t/controlling-the-url-generated-after-an-action-is-performed/137278/1 "2008-05-11T10:11:16Z")

</div>

Above my listing partial I have a form\_remote\_tag that encompasses a few  
collection\_selects for which the :submit =\> “Filter” action builds the  
appropriate :conditions for the database query. This works very well.

Below my listing partial I have my will\_paginate page links. This works  
very well.

I have been unable to get the two to work together though, because  
will\_paginate builds a URL of controller?page=… which trips up my  
Filter button somehow. In other words, if I’m not on page 1 (no  
pagination navigation links have been followed) my filter method is  
called properly. If I have used a pagination navigation link, my filter  
method (“do\_filter”) is listed in the development log this way: (No  
route matches “/do\_filter” with {:method=\>:post})

Conversely, if I have performed a filter, the pagination navigation  
links are built thusly, and so won’t work:  
[http://localhost:3000/controller/do\_filter?page=2](http://localhost:3000/controller/do_filter?page=2)

I have moved all of this to AJAX with a do\_filter.rjs that just does a  
page[:listing].reload

What more do I need to do to make sure the URLs getting passed around  
are correct? I’m not interested in search engines cacheing these page  
URLs as this is an internal project, and there’s no good reason to even  
bookmark a specific page or filter condition. I just don’t want the app  
blowing up when the user tries to go to page 2 of a filtered collection!

Thanks!!
