On 28 Feb 2008, at 03:56, Josh wrote:
>
> I would like to avoid creating sessions for users who are not logged
> in. To that end, I have added the following to my
> ApplicationController:
>
> session :off, :if => Proc.new { |req| req.session[:user_id].nil? }
>
I think the problem here is that you are accessing the request
session, which in turn causes a session to be created.
You need a way to say "give me the session if it exists, but if it
doesn''t exist don''t bother". A cursory glance at the
source
(cgi_process.rb is the interesting file suggests that there is no api
for this and you''ll just have to look for the presence of an @session
instance variable in the request object.
Fred> Based on my understanding, if the Proc returns true (e.g.
> session[:user_id] is null), a session will not be created. This does
> not seem to be working though as a session is always created in the
> DB. Any thoughts?
>
> Thanks,
> Josh
>
> --~--~---------~--~----~------------~-------~--~----~
> 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/rubyonra
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---