Hello folk... I''m wondering what the best practice is for passing referring actions to a new action. For example if I have an action that I use a million times in my application I want to be able to call it, and then be returned to the action that called it... whatever it may be. Currently I''m using parameters.... When I call the method with a link_to for example, I do something like this in the view... <%= link_to ''do this'' :action => ''do_this_action'', :id => @id_of_something, :from_controller => params[:controller], :from_action => params[:action] %> now... I''m 100% sure that''s not the way I should do it, because the URL becomes.... http://0.0.0.0/controller/action/1?from_controller=refering_controller&from_action=ref_action and then everyone knows the names of my actions... not only is it messy.... I''m sure there''s some security issues there too... I guess I could pass these things to a session, is that the best way? Thanks in advance guys! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin
2006-Sep-28 04:35 UTC
Re: Best Practices.... passing referring controller / action.
sw0rdfish ïèøåò:> I''m wondering what the best practice is for passing referring actions > to a new action. For example if I have an action that I use a million > times in my application I want to be able to call it, and then be > returned to the action that called it... whatever it may be. > > I guess I could pass these things to a session, is that the best way? > Thanks in advance guys!People use session to store the url where you need to return to. You can retrieve it with request.request_uri --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sw0rdfish
2006-Sep-28 14:15 UTC
Re: Best Practices.... passing referring controller / action.
So you would store the entire URL, and not just the action / controller? And request.request_uri returns the current URL? Anyone else have input on this? Not that I don''t trust Maxim, just more opions the better :) Thanks guys! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sw0rdfish
2006-Sep-28 14:18 UTC
Re: Best Practices.... passing referring controller / action.
So you would store the entire URL, and not just the action / controller? And request.request_uri returns the current URL? Anyone else have input on this? Not that I don''t trust Maxim, just more opions the better :) Thanks guys! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sw0rdfish
2006-Sep-28 14:28 UTC
Re: Best Practices.... passing referring controller / action.
I was looking around the recepie book, and it talks of using... request.env["HTTP_REFERER"] Would that work? P.S. sorry for the double post previosuly. Google went wonky on me. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin
2006-Sep-28 15:13 UTC
Re: Best Practices.... passing referring controller / action.
On 28 September 2006 18:28, sw0rdfish wrote:> I was looking around the recepie book, and it talks of using... > > request.env["HTTP_REFERER"]HTTP_REFERER is URL from which the HTTP request came (what page linked to current page).> Would that work?It depends on what do you want to store: current request URL or the one, from where user came to current page. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
sw0rdfish
2006-Sep-28 15:33 UTC
Re: Best Practices.... passing referring controller / action.
Well the ultimate goal is to be able to go back to the action I came from once I''m finished in the "current" action. Eg. View an Order -> call action "edit item name" -> go back to view order OR view and ITEM -> call action "edit item name" -> go back to view ITEM I want the action "edit item name" to be the same one for both calls, so I need to save the action I was in prior to calling "edit item name"... I think putting a filter action in the aplication.rb file that runs before each action calll to store the refering action / controller into a session would be a good way of doing it. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Vishnu Gopal
2006-Sep-29 06:17 UTC
Re: Best Practices.... passing referring controller / action.
redirect_back_or_default :action => ''action'' It comes with the login generator, but http://www.bigbold.com/snippets/posts/show/1052 Vish On 9/28/06, sw0rdfish <santia-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Well the ultimate goal is to be able to go back to the action I came > from once I''m finished in the "current" action. > > Eg. > > View an Order -> call action "edit item name" -> go back to view order > OR > view and ITEM -> call action "edit item name" -> go back to view ITEM > > I want the action "edit item name" to be the same one for both calls, > so I need to save the action I was in prior to calling "edit item > name"... > > I think putting a filter action in the aplication.rb file that runs > before each action calll to store the refering action / controller into > a session would be a good way of doing it. > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---