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! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
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 :) On Jun 16, 3:27 pm, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 :) 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! :) ( just posting here for google achieving :) ) On Jun 16, 3:35 pm, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 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 :) > > On Jun 16, 3:27 pm, sw0rdfish <san...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > 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!--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-Jun-16 21:55 UTC
Re: Is there a built in variable for the current path?
if you were using restful routing, just prefix the route with _url rather than _path: blogs_path becomes blogs_url --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---