newtorails.
2007-Jan-26 00:23 UTC
newbie alert! diff between @session[''user''].id and @session[:user].id
I struggled for sometime to use @session[:user].id while using LoginGenerator to retrieve id of the logged in user. In the end I could make it work with @session[''user''].id. Shouldn''t the two approaches be same? thanks. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Jan-26 01:13 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
Hi, you should be able to use script console to determine if they are
equivalent. For example,
irb(main):001:0> a = {}
=> {}
irb(main):002:0> a[:this] = ''foo''
=> "foo"
irb(main):003:0> a[:this]
=> "foo"
irb(main):004:0> a[''this''] = ''foo2''
=> "foo2"
irb(main):005:0> a[:this]
=> "foo"
irb(main):006:0> a[:this] == a[''this'']
=> false
Good luck,
-Conrad
On 1/25/07, newtorails. <smangla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:>
> I struggled for sometime to use @session[:user].id while using
> LoginGenerator to retrieve id of the logged in user. In the end I could
> make it work with @session[''user''].id. Shouldn''t
the two approaches be
> same?
>
> thanks.
>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---
newtorails.
2007-Jan-26 01:28 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
Ok, makes sense.. Thanks.. i think loginGenerator by default generates the code that use quotes for array reference. On Jan 25, 5:13 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, you should be able to use script console to determine if they are > equivalent. For example, > > irb(main):001:0> a = {} > => {} > irb(main):002:0> a[:this] = ''foo'' > => "foo" > irb(main):003:0> a[:this] > => "foo" > irb(main):004:0> a[''this''] = ''foo2'' > => "foo2" > irb(main):005:0> a[:this] > => "foo" > irb(main):006:0> a[:this] == a[''this''] > => false > > Good luck, > > -Conrad > > On 1/25/07, newtorails. <sman...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > I struggled for sometime to use @session[:user].id while using > > LoginGenerator to retrieve id of the logged in user. In the end I could > > make it work with @session[''user''].id. Shouldn''t the two approaches be > > same? > > > thanks.- Hide quoted text -- Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Rob Sanheim
2007-Jan-26 02:53 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
Actually, this may be misleading in the case of session, params, and other certain ''special'' hashes that Rails uses. Rails has a "HashWithIndifferentAccess" that allows accesing something by symbol _and_ key, so that session[:foo] == session[''foo'']. I''m not positive that session uses that hash, but you should test this right in a controller and not just in a plain irb session. - Rob On 1/25/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, you should be able to use script console to determine if they are > equivalent. For example, > > irb(main):001:0> a = {} > => {} > irb(main):002:0> a[:this] = ''foo'' > => "foo" > irb(main):003:0> a[:this] > => "foo" > irb(main):004:0> a[''this''] = ''foo2'' > => "foo2" > irb(main):005:0> a[:this] > => "foo" > irb(main):006:0> a[:this] == a[''this''] > => false > > Good luck, > > -Conrad > > On 1/25/07, newtorails. <smangla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > I struggled for sometime to use @session[:user].id while using > > LoginGenerator to retrieve id of the logged in user. In the end I could > > make it work with @session[''user''].id. Shouldn''t the two approaches be > > same? > > > > thanks. > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Matt Jones
2007-Jan-26 03:20 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
A note: accessing the session with @session[] has been deprecated for a while now (a few months). Try using just ''session[:user]''. --Matt On 1/25/07, newtorails. <smangla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I struggled for sometime to use @session[:user].id while using > LoginGenerator to retrieve id of the logged in user. In the end I could > make it work with @session[''user''].id. Shouldn''t the two approaches be > same? > > thanks. > > > > >-- Matt Jones mdj.acme-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org President/Technical Director, Acme Art Company (acmeartco.org) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Conrad Taylor
2007-Jan-26 13:08 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
Hi, my test using IRB was consistent with my test using sessions within a controller. Thus, the following isn''t equal: session[:user] != session[''user''] In general, they implemented session as global hash within Rails. -Conrad On 1/25/07, Rob Sanheim <rsanheim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Actually, this may be misleading in the case of session, params, and > other certain ''special'' hashes that Rails uses. Rails has a > "HashWithIndifferentAccess" that allows accesing something by symbol > _and_ key, so that session[:foo] == session[''foo'']. I''m not positive > that session uses that hash, but you should test this right in a > controller and not just in a plain irb session. > > - Rob > On 1/25/07, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, you should be able to use script console to determine if they are > > equivalent. For example, > > > > irb(main):001:0> a = {} > > => {} > > irb(main):002:0> a[:this] = ''foo'' > > => "foo" > > irb(main):003:0> a[:this] > > => "foo" > > irb(main):004:0> a[''this''] = ''foo2'' > > => "foo2" > > irb(main):005:0> a[:this] > > => "foo" > > irb(main):006:0> a[:this] == a[''this''] > > => false > > > > Good luck, > > > > -Conrad > > > > On 1/25/07, newtorails. <smangla-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > I struggled for sometime to use @session[:user].id while using > > > LoginGenerator to retrieve id of the logged in user. In the end I could > > > make it work with @session[''user''].id. Shouldn''t the two approaches be > > > same? > > > > > > thanks. > > > > > > > > > > > > > > > > > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
newtorails.
2007-Jan-26 19:12 UTC
Re: newbie alert! diff between @session[''user''].id and @session[:user].id
Matt, changing @session to session[..] doesn''t change the situation.. let me know if you see anything different. On Jan 26, 5:08 am, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi, my test using IRB was consistent with my test using sessions > within a controller. Thus, the following isn''t equal: > > session[:user] != session[''user''] > > In general, they implemented session as global hash within Rails. > > -Conrad > > On 1/25/07, Rob Sanheim <rsanh...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > > > Actually, this may be misleading in the case of session, params, and > > other certain ''special'' hashes that Rails uses. Rails has a > > "HashWithIndifferentAccess" that allows accesing something by symbol > > _and_ key, so that session[:foo] == session[''foo'']. I''m not positive > > that session uses that hash, but you should test this right in a > > controller and not just in a plain irb session. > > > - Rob > > On 1/25/07, Conrad Taylor <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Hi, you should be able to use script console to determine if they are > > > equivalent. For example, > > > > irb(main):001:0> a = {} > > > => {} > > > irb(main):002:0> a[:this] = ''foo'' > > > => "foo" > > > irb(main):003:0> a[:this] > > > => "foo" > > > irb(main):004:0> a[''this''] = ''foo2'' > > > => "foo2" > > > irb(main):005:0> a[:this] > > > => "foo" > > > irb(main):006:0> a[:this] == a[''this''] > > > => false > > > > Good luck, > > > > -Conrad > > > > On 1/25/07, newtorails. <sman...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > I struggled for sometime to use @session[:user].id while using > > > > LoginGenerator to retrieve id of the logged in user. In the end I could > > > > make it work with @session[''user''].id. Shouldn''t the two approaches be > > > > same? > > > > > thanks.- Hide quoted text -- Show quoted text ---~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---