Hi, I am a rails newbie and i need to store some info. in the session, so that i can use it in any controllers when needed. in config/enviroment.rb, i have, ---------------------------------------------------------- config.action_controller.session = { :session_key => ''_xxx_ui_session'', :secret => ''70ec05c894289359662252cdfd64e359822861bfd85626d0cc0699b4cef6ab409861e5dce5c9359918cedf4f58fa6fb73e2697ddb32d5ef4bd 4076cf31c1af8d'' } ---------------------------------------------------------- In application.rb, i have, ------------------------------------------------------------------------------------ class ApplicationController < ActionController::Base require ''xmlrpc_server'' @hostname = "127.0.0.1" @port = 8080 @server = ServerProxy.new(@hostname, @port) session[:server] = @server ===> i get the error for this line end ------------------------------------------------------------------------------------ But i keep on getting the error Symbol as array index Am i going wrong anywhere, please suggest Thanks and Regards, Vimal Das --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2009-Apr-01 08:34 UTC
Re: Storing information in session in rails - How to ?
On Apr 1, 7:39 am, vimal <cool.vimalsm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> In application.rb, i have, > --------------------------------------------------------------------------- --------- > class ApplicationController < ActionController::Base > require ''xmlrpc_server'' > > @hostname = "127.0.0.1" > @port = 8080 > @server = ServerProxy.new(@hostname, @port) > > session[:server] = @server ===> i get the error for this line > > end > --------------------------------------------------------------------------- --------- > But i keep on getting the error > Symbol as array index > > Am i going wrong anywhere, please suggestYes - the session doesn''t exist at that point (this code is run when the application is started, not when a request is being processed (which is the only time a session is available). Fred> > Thanks and Regards, > Vimal Das--~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
config.action_controller.session = { :session_key => ''_xxx_ui_session'', :secret => ''70ec05c894289359662252cdfd64e359822861bfd85626d0cc0699b4cef6ab409861e5dce5c9359918cedf4f58fa6fb73e2697ddb32d5ef4bd 4076cf31c1af8d'' } this code will work before version 2.3.2 but in rails 2.3.3 it is changed to config.action_controller.session = { :key => ''_xxx_ui_session'', :secret => ''70ec05c894289359662252cdfd64e359822861bfd85626d0cc0699b4cef6ab409861e5dce5c9359918cedf4f58fa6fb73e2697ddb32d5ef4bd 4076cf31c1af8d'' } On Wed, Apr 1, 2009 at 2:04 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > > On Apr 1, 7:39 am, vimal <cool.vimalsm...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > In application.rb, i have, > > > --------------------------------------------------------------------------- > --------- > > class ApplicationController < ActionController::Base > > require ''xmlrpc_server'' > > > > @hostname = "127.0.0.1" > > @port = 8080 > > @server = ServerProxy.new(@hostname, @port) > > > > session[:server] = @server ===> i get the error for this line > > > > end > > > --------------------------------------------------------------------------- > --------- > > But i keep on getting the error > > Symbol as array index > > > > Am i going wrong anywhere, please suggest > > Yes - the session doesn''t exist at that point (this code is run when > the application is started, not when a request is being processed > (which is the only time a session is available). > > Fred > > > > Thanks and Regards, > > Vimal Das > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your suggestions. But i need some additional suggestions, as i am a newbie in both rails and xmlrpc I have an xmlrpc client in ruby stored inside the controllers directory and guessing how to get the connection and store it in a session. All i want to do is, 1) Establish a connection only once and store the connection variable in session like --> session[:server_conn] = @server_conn 2) Request a cookie after authentication ad store that in session like --> session[:cookie] = @cookie So that i can access the session variables in other controllers too.... Regards, Vimal Das --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---