Hi, i''m adding a searching part to my app and need to give the user an easy way to toggle between searching by Registered / Activity Basically there will be a line of text at the top saying ''Searching by : Registered'', when the user clicks Registered (a link) it will revert it to searching by Activity, and vice versa. Should be simple enough but i''ve experimented with cookies and global variables in Ruby and getting nowhere fast. Should basically be a method which is fired when the user clicks the link and in turn flips a variables value from 1 to 0 and back again. Any ideas, stumped, -- 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 -~----------~----~----~----~------~----~------~--~---
John Griffiths wrote:> Hi, i''m adding a searching part to my app and need to give the user an > easy way to toggle between searching by Registered / Activity > > Basically there will be a line of text at the top saying ''Searching by : > Registered'', when the user clicks Registered (a link) it will revert it > to searching by Activity, and vice versa. > > Should be simple enough but i''ve experimented with cookies and global > variables in Ruby and getting nowhere fast. > > Should basically be a method which is fired when the user clicks the > link and in turn flips a variables value from 1 to 0 and back again. > > Any ideas, stumped,def toggle_regisistered_activity session[:reg_ac] ||= false (session[:reg_ac] = !session[:reg_ac]) ? (:registerd) : (:activity) end hth ilan -- 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 -~----------~----~----~----~------~----~------~--~---
Ilan Berci wrote:> John Griffiths wrote: >> Hi, i''m adding a searching part to my app and need to give the user an >> easy way to toggle between searching by Registered / Activity >> >> Basically there will be a line of text at the top saying ''Searching by : >> Registered'', when the user clicks Registered (a link) it will revert it >> to searching by Activity, and vice versa. >> >> Should be simple enough but i''ve experimented with cookies and global >> variables in Ruby and getting nowhere fast. >> >> Should basically be a method which is fired when the user clicks the >> link and in turn flips a variables value from 1 to 0 and back again. >> >> Any ideas, stumped, > > def toggle_regisistered_activity > session[:reg_ac] ||= false > (session[:reg_ac] = !session[:reg_ac]) ? (:registerd) : (:activity) > end > > hth > > ilanthanks, i''ll try that out. fingers crossed. -- 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 -~----------~----~----~----~------~----~------~--~---