Hi, I''m building an application that have many types of search requests like simple search, search within results, sort results, sort the displaying fields, show/hide fields... To do this I''m using several params[:X] variables which I''m passing all the time from one method to another. I''m passing those params with GET (through the URL) wich I don''t like at all. So: 1. which would be a better way to do it insteaf of GET?. And 2. is there an automated way to pass all the params (or the ones I''d choose) from one request to another? Thanks. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes, You can store all those variables in a session variable. Sessions allow you to store variables between requests, and give you ''state''. In your controllers, you can assign a session variable: def index session[:my_first_setting] = nil end def change_setting session[:my_first_setting] = params[:setting1] end def search order = session[:my_first_setting] ? "updated_at DESC" : "updated_at ASC" @results = Items.find(:all, :order => order) end You can store almost any data object in a session hash. On Mar 30, 12:18 pm, Fernando Poblete <rails-mailing-l...@andreas- s.net> wrote:> Hi, I''m building an application that have many types of search requests > like simple search, search within results, sort results, sort the > displaying fields, show/hide fields... > To do this I''m using several params[:X] variables which I''m passing all > the time from one method to another. > I''m passing those params with GET (through the URL) wich I don''t like at > all. So: > > 1. which would be a better way to do it insteaf of GET?. And > > 2. is there an automated way to pass all the params (or the ones I''d > choose) from one request to another? > > Thanks. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
First, thx for your answer. John Tajima wrote:> You can store all those variables in a session variable. Sessions > allow you to store variables between requests, and give you ''state''.Yes, sessions give you ''state'' which is the best approach for applications like a shopping cart. However, session is not good for me (I think) because the users of my application may use more than one navigation window and I don''t want ''state'' between them, wich will happen if I use sessions. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
You can use flash (ie. flash[:my_variable] = my_data) to pass information from one action to the next. Be careful how you use it. I have ran into some problems passing variables back to the same action using different request methods. On Mar 30, 10:35 am, Fernando Poblete <rails-mailing-l...@andreas- s.net> wrote:> First, thx for your answer. > > John Tajima wrote: > > You can store all those variables in a session variable. Sessions > > allow you to store variables between requests, and give you ''state''. > > Yes, sessions give you ''state'' which is the best approach for > applications like a shopping cart. However, session is not good for me > (I think) because the users of my application may use more than one > navigation window and I don''t want ''state'' between them, wich will > happen if I use sessions. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---