Is there a built in variable for the current path?

Probably a silly question, but I’m trying to create a partial that I
use in two seperate resources… one is called Tickets and one is
TicketsSearch.

I have links at the top of the page that order my seatrch by passing a
parameter into the ticket_path() variable…

Now I’d like to change that to the current path so that in
TicketsSearch I can use the same parameter and it would be like
saying

tickets_search_path( :order => date ) instead of ticket_path( :order
=> date ) w/o having to create an if statements and have two blocks of
table headers…

I hope that makes sense. Here’s my table header view if it helps.

http://pastie.textmate.org/private/dtth3tyeso8dluicug

Thanks!

oops… I was messing around trying stuff in that last pastie, I
forgot to fix it…

so ignore that base_path variable, or just look here…

http://pastie.textmate.org/private/4mho1rh36jpqejzprctdtg

thanks :slight_smile:

Ok I figured it out… after trying 100 different things…

url_for() does the trick for me.

request.request_uri returns the entire path including current query
strings, which I don’t want… nad I can’t pass t new query strings,
but url_for allows you to pass it an action, controller and
query_strings, and if you leave the action or controller out, it uses
the current one, which is perfect :slight_smile: now if I’m on the search, I get

http://0.0.0.0:3000/tickets_searches/2?order_by=tickets.date

and if I’m on the ticket listing… I get

http://0.0.0.0:3000/tickets/?order_by=tickets.date

sweet! :slight_smile:

( just posting here for google achieving :slight_smile: )

if you were using restful routing, just prefix the route with _url
rather
than _path:

blogs_path

becomes

blogs_url