Would someone please help i scrape the data and want to store in the @@job_list (class variable). However when I try to access the class variable from another action, it refers to another class variable. is there a way to work with initial grab data to be accessible within the controller, or do I have to temporarily store it in the database to use it? any help would be appreciated. Nick.B ex: class ListingController < ActionController @@job_list = JobSearch.new def list puts @@jobs @str = params[:search_str] if @str.nil? @jobs = nil else @jobs =@@jobs.get_all_jobs(@str) end end def index @search_str = "computer technician" end def search @search_str = params[:search_str] redirect_to params.merge(:controller=>''listing'', :action => ''list'') end def sort_by_date puts @@jobs # @jobs = @@jobs.sort_by_date render(:controller => ''listing'', :action => ''list'') end end -- 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 might be seeing this behavior if you''re running in development mode... controllers are reloaded upon every request in development and test. only in production mode are they loaded just once. class reloading settings can be changed in the various config/environments/ files i believe On Sep 25, 11:12 am, Nick Bhanji <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Would someone please help > > i scrape the data and want to store in the @@job_list (class variable). > However when I > try to access the class variable from another action, it refers to > another class variable. > > is there a way to work with initial grab data to be accessible within > the controller, or do > I have to temporarily store it in the database to use it? > > any help would be appreciated. > > Nick.B > ex: > > class ListingController < ActionController > @@job_list = JobSearch.new > > def list > puts @@jobs > @str = params[:search_str] > if @str.nil? > @jobs = nil > else > @jobs =@@jobs.get_all_jobs(@str) > end > end > def index > @search_str = "computer technician" > end > > def search > @search_str = params[:search_str] > redirect_to params.merge(:controller=>''listing'', :action => ''list'') > end > def sort_by_date > puts @@jobs > # @jobs = @@jobs.sort_by_date > render(:controller => ''listing'', :action => ''list'') > end > end > -- > 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 -~----------~----~----~----~------~----~------~--~---
Jeff Emminger wrote:> you might be seeing this behavior if you''re running in development > mode... controllers are reloaded upon every request in development and > test. only in production mode are they loaded just once. class > reloading settings can be changed in the various config/environments/ > files i believe > > > On Sep 25, 11:12 am, Nick Bhanji <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Thank you very much for that -- for a moment I thought I was insane to think one think and expect another. Would you know where I would change that value? -- 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 -~----------~----~----~----~------~----~------~--~---
development.rb. I wouldn''t rely on this: in production mode you will probably have 2 or more mongrels/fastcgis etc.... These independent processes will of course not share class variables set like that (and there''s no guarantee as to which mongrel handles a given incoming request) Fred -- 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 -~----------~----~----~----~------~----~------~--~---
in config/environments/[env].rb for example, to make development mode cache like production does, change the values in config/environments/development.rb to: config.cache_classes = true config.action_controller.perform_caching = true On Sep 27, 10:13 am, Nick Bhanji <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Jeff Emminger wrote: > > you might be seeing this behavior if you''re running in development > > mode... controllers are reloaded upon every request in development and > > test. only in production mode are they loaded just once. class > > reloading settings can be changed in the various config/environments/ > > files i believe > > > On Sep 25, 11:12 am, Nick Bhanji <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Thank you very much for that -- for a moment I thought I was insane to > think one think and expect another. Would you know where I would change > that value? > -- > 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> development.rb. I wouldn''t rely on this: in production mode you will > probably have 2 or more mongrels/fastcgis etc.... These independent > processes will of course not share class variables set like that (and > there''s no guarantee as to which mongrel handles a given incoming > request) > > FredThe biggest reason to use class variable, once and object is initialized -- that variable is accessible to it I am thinking of the solution that once a search is executed from one_client, i expect that client will interact with result until the new search is requested or session has expired. I am also am assuming that each client will create their own session therefore, that that is only available to that person. If I am thinking wrong, please help me understand where my mistake is. Nick. Bhanji. Thanks again. -- 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 -~----------~----~----~----~------~----~------~--~---
On 27 Sep 2007, at 16:44, Nick Bhanji wrote:> > Frederick Cheung wrote: >> development.rb. I wouldn''t rely on this: in production mode you will >> probably have 2 or more mongrels/fastcgis etc.... These independent >> processes will of course not share class variables set like that (and >> there''s no guarantee as to which mongrel handles a given incoming >> request) >> >> Fred > The biggest reason to use class variable, once and object is > initialized > -- that variable is accessible to it > > > I am thinking of the solution that once a search is executed from > one_client, i expect that client will interact with result until > the new > search is requested or session has expired. I am also am assuming > that > each client will create their own session therefore, that that is only > available to that person. >Those class variables aren''t session specific, they are instance of mongrel specific. So if you only have one mongrel, then everyone shares the same one. If there are two or mongrels then it''s a mix: when you look at the list action it might be handled by the first mongrel, but when you look at the sort_by_date action then that could be handled by a different mongrel, with its own copy of @@job_list. I''m not entirely sure what you''re trying to do but it sounds very much like class variables are not what you want (database or memcache or backgroundrb would probably be more suited) Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 27 Sep 2007, at 16:44, Nick Bhanji wrote: > >> initialized >> > Those class variables aren''t session specific, they are instance of > mongrel specific. So if you only have one mongrel, then everyone > shares the same one. If there are two or mongrels then it''s a mix: > when you look at the list action it might be handled by the first > mongrel, but when you look at the sort_by_date action then that could > be handled by a different mongrel, with its own copy of @@job_list. > > I''m not entirely sure what you''re trying to do but it sounds very > much like class variables are not what you want (database or memcache > or backgroundrb would probably be more suited) > > FredI just found out what you are trying to say. well, how would I solve the problem that each session has its instance object i.e job_list? Thank you for helping me -- Nick B -- 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 -~----------~----~----~----~------~----~------~--~---
On 27 Sep 2007, at 18:03, Nick Bhanji wrote:> > I just found out what you are trying to say. well, how would I solve > the problem that each session has its instance object i.e job_list? > >Don''t use class variables. Do use the database, memcache etc... backgroundrb (at least the old version) also allows you to share a cache of ruby objects. Fred