Forum: Ruby on Rails Using request.env to persist data?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
6663ba8c6b340de3046a0baff522bdde?d=identicon&s=25 tatyree (Guest)
on 2009-02-03 19:47
(Received via mailing list)
Is it ever sensible to attempt to persist data across a session using
request.env?  Say something like:

request.env['user_name'] = 'bob'

I'm discussing this with the maintainer of a commercial gem (where it
doesn't seem to work).

My natural instinct would be to do this instead (indeed, I patched the
gem):

session[:user_name] = 'bob'

I'm guessing that his use of request.env is derived from experience in
another language (PHP?) and I just wanted to check that it wasn't some
obscure, but reasonable, railsian way of doing things (that wasn't
working on any of my three environments) before I went back to him.

Cheers,
Todd
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-02-03 19:55
(Received via mailing list)
On 3 Feb 2009, at 18:47, tatyree wrote:

>
> Is it ever sensible to attempt to persist data across a session using
> request.env?  Say something like:
>
> request.env['user_name'] = 'bob'
>
> I'm discussing this with the maintainer of a commercial gem (where it
> doesn't seem to work).
>

Nope not a chance in hell. The request environment last for the
duration of the request.

> My natural instinct would be to do this instead (indeed, I patched the
> gem):
>
> session[:user_name] = 'bob'
>
That's what I would
6663ba8c6b340de3046a0baff522bdde?d=identicon&s=25 tatyree (Guest)
on 2009-02-03 20:01
(Received via mailing list)
Thank Frederick,

> Nope not a chance in hell. The request environment last for the  
> duration of the request.

That's exactly what I though.

Cheers,
Todd
3131fcea0a711e5ad89c8d49cc9253b4?d=identicon&s=25 Julian Leviston (Guest)
on 2009-02-04 00:46
(Received via mailing list)
Across a session, or a request/response loop?


Blog: http://random8.zenunit.com/
Learn rails: http://sensei.zenunit.com/
This topic is locked and can not be replied to.