Greg Hauptmann
2006-Nov-25 22:55 UTC
new session records in DB don''t get created until after "after_filter"s have run????
Hi, I''m using active record for sessions. I''m just noting that in terms of picking up the number of active users from the "session" table, that this works fine however it seems to MISS picking up one''s own active session for the situation when it is first access to the page (i.e. it the request where your session gets created). For example if I navigate to my site: - first hit: active users list don''t include me (as it seems the session record is not yet in the sessions table)??? - subsequent hits to site: everything is then fine Can anyone tell me how to ensure the newly created session is persisted to the database prior to the "before_filter"s running?? (i.e. I use a before filter to populate an instance variable with the list of active users, i..e from a query to the database)??? Tks --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2006-Nov-26 05:31 UTC
Re: new session records in DB don''t get created until after "after_filter"s have run????
just tried putting a "redirect params" for these cases so that in these cases once the session is setup the browser is instructed to ask again :) Not idea re response time re forcing another request from browser but it works and I''m not sure how else to handle this.....??? On 11/26/06, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I''m using active record for sessions. I''m just noting that in terms of > picking up the number of active users from the "session" table, that this > works fine however it seems to MISS picking up one''s own active session for > the situation when it is first access to the page ( i.e. it the request > where your session gets created). > > For example if I navigate to my site: > - first hit: active users list don''t include me (as it seems the session > record is not yet in the sessions table)??? > - subsequent hits to site: everything is then fine > > Can anyone tell me how to ensure the newly created session is persisted to > the database prior to the "before_filter"s running?? (i.e. I use a before > filter to populate an instance variable with the list of active users, i..e > from a query to the database)??? > > Tks > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
s.ross
2006-Nov-26 06:00 UTC
Re: new session records in DB don''t get created until after "after_filter"s have run????
Just my $.02, but I think you''re overloading the session. You have users, so marking their last activity datetime when they hit the site and offline if they''ve been idle for some arbitrary amount of time might make more sense. You could have a background job handle marking the users as inactive or do it in one SQL update query. Greg Hauptmann-3 wrote:> > just tried putting a "redirect params" for these cases so that in these > cases once the session is setup the browser is instructed to ask again :) > Not idea re response time re forcing another request from browser but it > works and I''m not sure how else to handle this.....??? > > > > On 11/26/06, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> >> Hi, >> >> I''m using active record for sessions. I''m just noting that in terms of >> picking up the number of active users from the "session" table, that this >> works fine however it seems to MISS picking up one''s own active session >> for >> the situation when it is first access to the page ( i.e. it the request >> where your session gets created). >> >> For example if I navigate to my site: >> - first hit: active users list don''t include me (as it seems the session >> record is not yet in the sessions table)??? >> - subsequent hits to site: everything is then fine >> >> Can anyone tell me how to ensure the newly created session is persisted >> to >> the database prior to the "before_filter"s running?? (i.e. I use a before >> filter to populate an instance variable with the list of active users, >> i..e >> from a query to the database)??? >> >> Tks >> >> > > > > >-- View this message in context: http://www.nabble.com/-Rails--new-session-records-in-DB-don%27t-get-created-until-after-%22after_filter%22s-have-run-----tf2705243.html#a7545083 Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---
Greg Hauptmann
2006-Nov-26 07:27 UTC
Re: new session records in DB don''t get created until after "after_filter"s have run????
tks - I''m effectively doing this I think (if I interpret your suggestion correctly) - the minor implementation issue I have seems to be due to the way that rails "active record session" mechanism for storing session state work. It seems to only push the details of a new session to the database after the "before_filter" and "after_filter" points, so that means during a "before_filter" when I query the sessions table the new session isn''t in there yet. Hope this makes sense? Wasn''t exactly sure what you meant re how to get around the above? On 11/26/06, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > Just my $.02, but I think you''re overloading the session. You have users, > so > marking their last activity datetime when they hit the site and offline if > they''ve been idle for some arbitrary amount of time might make more sense. > You could have a background job handle marking the users as inactive or do > it in one SQL update query. > > > Greg Hauptmann-3 wrote: > > > > just tried putting a "redirect params" for these cases so that in these > > cases once the session is setup the browser is instructed to ask again > :) > > Not idea re response time re forcing another request from browser but it > > works and I''m not sure how else to handle this.....??? > > > > > > > > On 11/26/06, Greg Hauptmann <greg.hauptmann.ruby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> > >> Hi, > >> > >> I''m using active record for sessions. I''m just noting that in terms > of > >> picking up the number of active users from the "session" table, that > this > >> works fine however it seems to MISS picking up one''s own active session > >> for > >> the situation when it is first access to the page ( i.e. it the request > >> where your session gets created). > >> > >> For example if I navigate to my site: > >> - first hit: active users list don''t include me (as it seems the > session > >> record is not yet in the sessions table)??? > >> - subsequent hits to site: everything is then fine > >> > >> Can anyone tell me how to ensure the newly created session is persisted > >> to > >> the database prior to the "before_filter"s running?? (i.e. I use a > before > >> filter to populate an instance variable with the list of active users, > >> i..e > >> from a query to the database)??? > >> > >> Tks > >> > >> > > > > > > > > > > > -- > View this message in context: > http://www.nabble.com/-Rails--new-session-records-in-DB-don%27t-get-created-until-after-%22after_filter%22s-have-run-----tf2705243.html#a7545083 > Sent from the RubyOnRails Users mailing list archive at Nabble.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 -~----------~----~----~----~------~----~------~--~---