Re: [jruby-user] accessing the session from the model

Aristedes Maniatis <[email protected]> Fri, 30 Jan 2015 11:53:39 +1100
Newsgroups gmane.comp.lang.jruby.user
Message-ID <[email protected]>
Any thoughts about how to get access to the session object from the Rails model?

Ari


On 29/01/2015 10:17pm, Karol Bucek wrote:
> 
> ... the session_store initializer will replace the underlying engine behind *session* Hash (wherever it is used from), you just keep using session[:data] as usual
> 
> the underlying store is thread-safe but please note that it only works under a servlet container (with JRuby-Rack), passenger links are not really useful here ...
> 
> K.
> 
> On Wed, Jan 28, 2015 at 7:54 AM, Aristedes Maniatis <[email protected] <mailto:[email protected]>> wrote:
> 
>     Environment: jruby 1.7.18 with Rails 4.0.x
> 
>     In order to use Rails in a way I'm more familiar (with a server-side session store that integrates deeply with the model), I want to access the servlet session from the Rails model. Now the typical integration approach is this:
> 
> 
>     # config/initializers/session_store.rb
>     if defined?($servlet_context)
>        require 'action_controller/session/java_servlet_store'
>        ActionController::Base.session_store = :java_servlet_store end
>     end
> 
>     But how can I get access to that store from the model without running into threading issues? I've found some comments [1] but I'm not quite sure of the threading approach inside jruby to understand how to access the current user's session from the model.
> 
> 
>     Thanks
>     Ari
> 
> 
> 
> 
>     [1] http://stackoverflow.com/questions/4280044/confirm-on-apache-passenger-deployment-rails-access-session-in-model
> 
>     --
>     -------------------------->
>     Aristedes Maniatis
>     ish
>     http://www.ish.com.au
>     Level 1, 30 Wilson Street Newtown 2042 Australia
>     phone +61 2 9550 5001 <tel:%2B61%202%209550%205001>   fax +61 2 9550 4001 <tel:%2B61%202%209550%204001>
>     GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A
> 
>     ---------------------------------------------------------------------
>     To unsubscribe from this list, please visit:
> 
>         http://xircles.codehaus.org/manage_email
> 
> 
> 

-- 
-------------------------->
Aristedes Maniatis
ish
http://www.ish.com.au
Level 1, 30 Wilson Street Newtown 2042 Australia
phone +61 2 9550 5001   fax +61 2 9550 4001
GPG fingerprint CBFB 84B4 738D 4E87 5E5C  5EFA EF6A 7D2E 3E49 102A

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email